Commits

Alex Szpakowski committed 6270afb

Fixed ChainShape:getChildEdge crashing

  • Participants
  • Parent commits 7ad34b8

Comments (0)

Files changed (2)

File src/modules/physics/box2d/ChainShape.cpp

 EdgeShape *ChainShape::getChildEdge(int index) const
 {
 	b2ChainShape *c = (b2ChainShape *)shape;
-	b2EdgeShape e;
-	c->GetChildEdge(&e, index);
-	EdgeShape *edge = (EdgeShape *)Memoizer::find(&e);
-	if (!edge)
-		return new EdgeShape(&e);
-	else
+	b2EdgeShape *e = new b2EdgeShape;
+
+	try
 	{
-		edge->retain();
-		return edge;
+		c->GetChildEdge(e, index);
 	}
+	catch (love::Exception &ex)
+	{
+		delete e;
+		throw;
+	}
+
+	return new EdgeShape(e, true);
 }
 
 int ChainShape::getChildCount() const

File src/modules/physics/box2d/wrap_ChainShape.cpp

 {
 	ChainShape *c = luax_checkchainshape(L, 1);
 	int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
-	EdgeShape *e = c->getChildEdge(index);
+	EdgeShape *e = 0;
+	ASSERT_GUARD(e = c->getChildEdge(index);)
 	luax_newtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, e);
 	return 1;
 }