Fixed a small memory leak if love.physics.newChainShape errors

This commit is contained in:
Alex Szpakowski
2013-12-10 03:54:56 -04:00
parent 5b66cd2290
commit 760f8220fa
+14 -6
View File
@@ -149,16 +149,24 @@ int Physics::newChainShape(lua_State *L)
lua_pop(L, 2);
}
if (loop)
s->CreateLoop(vecs, vcount);
else
s->CreateChain(vecs, vcount);
try
{
if (loop)
s->CreateLoop(vecs, vcount);
else
s->CreateChain(vecs, vcount);
}
catch (love::Exception &)
{
delete[] vecs;
throw;
}
ChainShape *c = new ChainShape(s);
delete[] vecs;
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, c);
ChainShape *c = new ChainShape(s);
luax_pushtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, c);
return 1;
}