]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/quantize.cpp
fixing overrelease and out-of-bounds write, fixes #13725
[wxWidgets.git] / src / common / quantize.cpp
index 695375657ce5bf68dcf0d77ef9049a11f78786a3..cbd53cc46838d09712fa128776cccb38ff4409fd 100644 (file)
 #pragma hdrstop
 #endif
 
 #pragma hdrstop
 #endif
 
-#ifndef WX_PRECOMP
-    #include "wx/palette.h"
-#endif
-
 #if wxUSE_IMAGE
 
 #if wxUSE_IMAGE
 
-#include "wx/image.h"
 #include "wx/quantize.h"
 
 #include "wx/quantize.h"
 
+#ifndef WX_PRECOMP
+    #include "wx/palette.h"
+    #include "wx/image.h"
+#endif
+
 #ifdef __WXMSW__
 #ifdef __WXMSW__
-#include "wx/msw/private.h"
+    #include "wx/msw/private.h"
 #endif
 
 #include <stdlib.h>
 #endif
 
 #include <stdlib.h>
@@ -1546,7 +1546,7 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest,
 
     if (flags & wxQUANTIZE_FILL_DESTINATION_IMAGE)
     {
 
     if (flags & wxQUANTIZE_FILL_DESTINATION_IMAGE)
     {
-        if (!dest.Ok())
+        if (!dest.IsOk())
             dest.Create(w, h);
 
         imgdt = dest.GetData();
             dest.Create(w, h);
 
         imgdt = dest.GetData();
@@ -1621,7 +1621,9 @@ bool wxQuantize::Quantize(const wxImage& src, wxImage& dest,
         delete[] g;
         delete[] b;
     }
         delete[] g;
         delete[] b;
     }
-#endif // wxUSE_PALETTE
+#else // !wxUSE_PALETTE
+    wxUnusedVar(pPalette);
+#endif // wxUSE_PALETTE/!wxUSE_PALETTE
 
     return true;
 }
 
     return true;
 }