From 2ae4e9cd5ae4a09318784f4a6a1ccfa620d453b0 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 18 Jun 2014 16:24:38 -0300 Subject: [PATCH] Fixed a potential memory leak in the love.physics World callbacks. --- src/modules/physics/box2d/World.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/physics/box2d/World.cpp b/src/modules/physics/box2d/World.cpp index bf6f6ee1b..400772ffd 100644 --- a/src/modules/physics/box2d/World.cpp +++ b/src/modules/physics/box2d/World.cpp @@ -131,6 +131,8 @@ bool World::ContactFilter::process(Fixture *a, Fixture *b) if (ref != 0) { + a->retain(); + b->retain(); lua_State *L = ref->getL(); ref->push(); luax_pushtype(L, "Fixture", PHYSICS_FIXTURE_T, a); @@ -318,11 +320,9 @@ bool World::ShouldCollide(b2Fixture *fixtureA, b2Fixture *fixtureB) Fixture *a = (Fixture *)Memoizer::find(fixtureA); if (!a) throw love::Exception("A fixture has escaped Memoizer!"); - a->retain(); Fixture *b = (Fixture *)Memoizer::find(fixtureB); if (!b) throw love::Exception("A fixture has escaped Memoizer!"); - b->retain(); return filter.process(a, b); }