X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6e3d5828092893fa94725ecc09a6a84c9286ccda..f262b25c93c89d2f2bd0b388bac293c8969a2d72:/src/common/imagtga.cpp diff --git a/src/common/imagtga.cpp b/src/common/imagtga.cpp index 281682cbb9..6d65dd7889 100644 --- a/src/common/imagtga.cpp +++ b/src/common/imagtga.cpp @@ -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; }