From c96ade1cf0a1a3aeeb6dcfcdfd4c57f568728ed3 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Wed, 15 Sep 2010 21:10:46 +0200 Subject: [PATCH] Prevented a memory leak in the setFont wrapper --- src/modules/graphics/opengl/wrap_Graphics.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 38e1c691c..399fbaee3 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -381,8 +381,11 @@ namespace opengl Font * font; + bool created = false; + // If the first parameter isn't a Font, create a new one if (!luax_istype(L, 1, GRAPHICS_FONT_T)) { + created = true; lua_pushinteger(L, size); // push the size lua_insert(L, 2); // move it to its proper place // Convert to File, if necessary. @@ -418,6 +421,8 @@ namespace opengl } else font = luax_checktype(L, 1, "Font", GRAPHICS_FONT_T); instance->setFont(font); + if (created) + font->release(); return 0; }