diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index 7d57614e08..b018365cfb 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -805,21 +805,25 @@ read_args() { #elif defined(IS_FREEBSD) // In FreeBSD, we can use sysctl to determine the command-line arguments. - size_t bufsize = 4096; - char buffer[4096]; + size_t bufsize = 0; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, 0}; mib[3] = getpid(); - if (sysctl(mib, 4, (void*) buffer, &bufsize, nullptr, 0) == -1) { + if (sysctl(mib, 4, nullptr, &bufsize, nullptr, 0) == -1) { perror("sysctl"); } else { - if (_binary_name.empty()) { - _binary_name = buffer; - } - size_t idx = strlen(buffer) + 1; - while (idx < bufsize) { - _args.push_back((char*)(buffer + idx)); - size_t newidx = strlen(buffer + idx); - idx += newidx + 1; + char *buffer = (char *)alloca(bufsize); + if (sysctl(mib, 4, buffer, &bufsize, nullptr, 0) == -1) { + perror("sysctl"); + } else { + if (_binary_name.empty()) { + _binary_name = buffer; + } + size_t idx = strlen(buffer) + 1; + while (idx < bufsize) { + _args.push_back((char*)(buffer + idx)); + size_t newidx = strlen(buffer + idx); + idx += newidx + 1; + } } } diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index 6f3d3e39f2..cc3eef4810 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -527,8 +527,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { max_dist = csqrt(max_dist_2); } - if (dist > max_dist) { - // There's no intersection: the sphere is hanging off the edge. + if (dist > max_dist || -dist > max_dist) { + // There's no intersection: the sphere is hanging above or under the edge. return nullptr; } diff --git a/panda/src/collide/collisionPolygon.h b/panda/src/collide/collisionPolygon.h index 9782d6cf01..045bcc7183 100644 --- a/panda/src/collide/collisionPolygon.h +++ b/panda/src/collide/collisionPolygon.h @@ -32,12 +32,12 @@ PUBLISHED: const LVecBase3 &c); INLINE CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, const LVecBase3 &c, const LVecBase3 &d); - INLINE CollisionPolygon(const LPoint3 *begin, const LPoint3 *end); private: INLINE CollisionPolygon(); public: + INLINE CollisionPolygon(const LPoint3 *begin, const LPoint3 *end); CollisionPolygon(const CollisionPolygon ©); virtual CollisionSolid *make_copy(); diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index cef27dc125..8430d3d59d 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -798,6 +798,12 @@ void PythonTask:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); + // If we were polling something when we were removed, get rid of it. + if (_future_done != nullptr) { + Py_DECREF(_future_done); + _future_done = nullptr; + } + if (_upon_death != Py_None) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) // Use PyGILState to protect this asynchronous call.