fix memory leak when calling initializePolyhedralFeatures

Fixes Issue 623, thanks for the report/patch!
This commit is contained in:
erwin.coumans
2012-09-08 19:43:24 +00:00
parent f3d40957be
commit 2700ba17c0

View File

@@ -31,6 +31,7 @@ btPolyhedralConvexShape::~btPolyhedralConvexShape()
{ {
if (m_polyhedron) if (m_polyhedron)
{ {
m_polyhedron->~btConvexPolyhedron();
btAlignedFree(m_polyhedron); btAlignedFree(m_polyhedron);
} }
} }
@@ -40,7 +41,10 @@ bool btPolyhedralConvexShape::initializePolyhedralFeatures()
{ {
if (m_polyhedron) if (m_polyhedron)
{
m_polyhedron->~btConvexPolyhedron();
btAlignedFree(m_polyhedron); btAlignedFree(m_polyhedron);
}
void* mem = btAlignedAlloc(sizeof(btConvexPolyhedron),16); void* mem = btAlignedAlloc(sizeof(btConvexPolyhedron),16);
m_polyhedron = new (mem) btConvexPolyhedron; m_polyhedron = new (mem) btConvexPolyhedron;