mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Add NULL initializers for pointers.
Constructing invalid shapes, e.g. a rectangle with width 0, could result in a b2Assert to fail. In turn, Shape::~Shape tried to destroy a the shape with an uninitialized pointer, yielding a segfault. Add NULL-initializers and checks for NULL to prevent this.
This commit is contained in:
@@ -34,7 +34,7 @@ namespace physics
|
||||
namespace box2d
|
||||
{
|
||||
Shape::Shape(Body * body)
|
||||
: body(body)
|
||||
: body(body), shape(NULL)
|
||||
{
|
||||
body->retain();
|
||||
data = new shapeudata();
|
||||
@@ -49,7 +49,8 @@ namespace box2d
|
||||
delete data;
|
||||
data = 0;
|
||||
|
||||
body->body->DestroyShape(shape);
|
||||
if (shape)
|
||||
body->body->DestroyShape(shape);
|
||||
shape = 0;
|
||||
|
||||
body->release();
|
||||
|
||||
Reference in New Issue
Block a user