From 2e21435f432191afa1b0f609daa8ca9d4cde1e93 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Sep 2012 20:00:25 +0200 Subject: Some memory leaks fixed --- src/graphics/engine/text.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/graphics/engine/text.cpp') diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 19ef57b..8fc8709 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -785,18 +785,20 @@ Gfx::CharTexture Gfx::CText::CreateCharTexture(Gfx::UTF8Char ch, Gfx::CachedFont data.surface = nullptr; - SDL_FreeSurface(textSurface); - SDL_FreeSurface(textureSurface); - if (! tex.Valid()) { m_error = "Texture create error"; return texture; } + else + { + texture.id = tex.id; + texture.texSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textureSurface->w, textureSurface->h)); + texture.charSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textSurface->w, textSurface->h)); + } - texture.id = tex.id; - texture.texSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textureSurface->w, textureSurface->h)); - texture.charSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textSurface->w, textSurface->h)); + SDL_FreeSurface(textSurface); + SDL_FreeSurface(textureSurface); return texture; } -- cgit v1.2.3-1-g7c22