From c1e32e64284e63c3a748f283d6700129a2b32669 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 7 Jun 2017 19:00:44 -0700 Subject: [PATCH] fix potential memory leaks --- .../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp | 2 ++ examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp | 8 ++++++++ examples/SharedMemory/PhysicsServerExample.cpp | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp b/examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp index c14658ab9..e0301587a 100644 --- a/examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp +++ b/examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp @@ -64,8 +64,10 @@ bool b3ImportMeshUtility::loadAndRegisterMeshFromFileInternal(const std::string& meshData.m_textureHeight = height; } else { + b3Warning("Unsupported texture image format [%s]\n",relativeFileName); meshData.m_textureWidth = 0; meshData.m_textureHeight = 0; + break; } } else diff --git a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp index d243c1bc9..86f707a2f 100644 --- a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp +++ b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp @@ -1243,6 +1243,14 @@ btCollisionShape* BulletURDFImporter::getAllocatedCollisionShape(int index) const UrdfCollision& col = link->m_collisionArray[v]; btCollisionShape* childShape = convertURDFToCollisionShape(&col ,pathPrefix); m_data->m_allocatedCollisionShapes.push_back(childShape); + if (childShape->getShapeType()==COMPOUND_SHAPE_PROXYTYPE) + { + btCompoundShape* compound = (btCompoundShape*) childShape; + for (int i=0;igetNumChildShapes();i++) + { + m_data->m_allocatedCollisionShapes.push_back(compound->getChildShape(i)); + } + } if (childShape) { diff --git a/examples/SharedMemory/PhysicsServerExample.cpp b/examples/SharedMemory/PhysicsServerExample.cpp index 1180dcfd8..cbf7427bb 100644 --- a/examples/SharedMemory/PhysicsServerExample.cpp +++ b/examples/SharedMemory/PhysicsServerExample.cpp @@ -723,6 +723,11 @@ public: virtual ~MultiThreadedOpenGLGuiHelper() { //delete m_childGuiHelper; + if (m_debugDraw) + { + delete m_debugDraw; + m_debugDraw = 0; + } } void setCriticalSection(b3CriticalSection* cs)