X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..96461cc29d03b4a7ab72abaae2e7edace93dd2a5:/src/png/example.c?ds=sidebyside diff --git a/src/png/example.c b/src/png/example.c index 7956cf7abd..ba0ecc5b5c 100644 --- a/src/png/example.c +++ b/src/png/example.c @@ -631,7 +631,7 @@ void write_png(char *file_name /* , ... other image information ... */) /* set the palette if there is one. REQUIRED for indexed-color images */ palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH - * sizeof (png_color)); + * png_sizeof (png_color)); /* ... set palette colors ... */ png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); /* You must not free palette here, because png_set_PLTE only makes a link to @@ -741,6 +741,10 @@ void write_png(char *file_name /* , ... other image information ... */) png_uint_32 k, height, width; png_byte image[height][width*bytes_per_pixel]; png_bytep row_pointers[height]; + + if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) + png_error (png_ptr, "Image is too tall to process in memory"); + for (k = 0; k < height; k++) row_pointers[k] = image + k*width*bytes_per_pixel;