From cf2bfcc4a2372f9ba252c3c221a39e8739ab3a3e Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 12 Nov 2011 15:00:26 +0100 Subject: [PATCH] Fix more memory leaks (issue #327) --- src/modules/physics/box2d/World.cpp | 2 +- src/modules/thread/wrap_Thread.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/physics/box2d/World.cpp b/src/modules/physics/box2d/World.cpp index 8e292d7c6..64c6dcd1b 100644 --- a/src/modules/physics/box2d/World.cpp +++ b/src/modules/physics/box2d/World.cpp @@ -77,7 +77,7 @@ namespace box2d Contact * c = new Contact(contact); - luax_newtype(L, "Contact", (PHYSICS_CONTACT_T), (void*)c, false); + luax_newtype(L, "Contact", (PHYSICS_CONTACT_T), (void*)c, true); int args = 3; if (impulse) { diff --git a/src/modules/thread/wrap_Thread.cpp b/src/modules/thread/wrap_Thread.cpp index 93a11bf32..6d1386264 100644 --- a/src/modules/thread/wrap_Thread.cpp +++ b/src/modules/thread/wrap_Thread.cpp @@ -262,8 +262,13 @@ namespace thread } } else + { data = luax_checktype(L, 2, "Data", DATA_T); + data->retain(); + } Thread *t = instance->newThread(name, data); + // do not worry, file->read() returns retained data + data->release(); if (!t) return luaL_error(L, "A thread with that name already exists."); luax_newtype(L, "Thread", THREAD_THREAD_T, (void*)t);