Browse Source

Fixed a potential memory leak when a Font object errors

Alex Szpakowski 11 years ago
parent
commit
9b9671f5ee
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/modules/graphics/opengl/Font.cpp

+ 9 - 1
src/modules/graphics/opengl/Font.cpp

@@ -186,7 +186,15 @@ Font::Glyph *Font::addGlyph(uint32 glyph)
 	if (textureY + h + TEXTURE_PADDING > textureHeight)
 	if (textureY + h + TEXTURE_PADDING > textureHeight)
 	{
 	{
 		// totally out of space - new texture!
 		// totally out of space - new texture!
-		createTexture();
+		try
+		{
+			createTexture();
+		}
+		catch (love::Exception &)
+		{
+			gd->release();
+			throw;
+		}
 	}
 	}
 
 
 	Glyph *g = new Glyph;
 	Glyph *g = new Glyph;