]> git.saurik.com Git - wxWidgets.git/commitdiff
ensure that image data is always freed by using wxON_BLOCK_EXIT in ReadTGA() (coverit...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 27 Nov 2006 15:01:58 +0000 (15:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 27 Nov 2006 15:01:58 +0000 (15:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/imagtga.cpp

index 281682cbb9f6773bdcb49d090d1011a649abfeae..6d65dd788929cad8b8961ce84ce6d51b8a61b747 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "wx/imagtga.h"
 #include "wx/log.h"
+#include "wx/scopeguard.h"
 
 // ----------------------------------------------------------------------------
 // constants
@@ -187,6 +188,8 @@ int ReadTGA(wxImage* image, wxInputStream& stream)
         return wxTGA_MEMERR;
     }
 
+    wxON_BLOCK_EXIT1(free, imageData);
+
     unsigned char *dst = image->GetData();
 
     unsigned char* alpha = NULL;
@@ -626,8 +629,6 @@ int ReadTGA(wxImage* image, wxInputStream& stream)
             return wxTGA_INVFORMAT;
     }
 
-    free(imageData);
-
     return wxTGA_OK;
 }