]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/imagpng.cpp
Fixed heap corruption when reading a corrupted RLE TGA image.
[wxWidgets.git] / src / common / imagpng.cpp
index 70e2a0abac679ce7f6c3e1f5e682fb93bbf782bb..41b13785285edd78ea8ac33f8654613cb6c6b94e 100644 (file)
@@ -522,7 +522,7 @@ wxPNGHandler::LoadFile(wxImage *image,
     png_structp png_ptr = png_create_read_struct
                           (
                             PNG_LIBPNG_VER_STRING,
-                            (voidp) NULL,
+                            NULL,
                             wx_png_error,
                             wx_png_warning
                           );
@@ -774,6 +774,15 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos
     bool bUsePalette = false;
 #endif // wxUSE_PALETTE
 
+    /*
+    If saving palettised was requested but it was decided we can't use a
+    palette then reset the colour type to RGB.
+    */
+    if (!bUsePalette && iColorType == wxPNG_TYPE_PALETTE)
+    {
+        iColorType = wxPNG_TYPE_COLOUR;
+    }
+
     bool bUseAlpha = !bUsePalette && (bHasAlpha || bHasMask);
 
     png_color mask;