Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pngminus/pnm2png.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ BOOL do_pnm2png (png_struct *png_ptr, png_info *info_ptr,
/* allocate the rows using the same memory layout as libpng, and transfer
* their ownership to libpng, with the responsibility to clean everything up;
* please note the use of png_calloc instead of png_malloc */
/* Guard against integer overflow: height * sizeof(png_byte*) can wrap on
* 32-bit systems when height is large, producing a tiny allocation that
* subsequent writes overrun. */
if (height > PNG_SIZE_MAX / sizeof (png_byte *))
png_error (png_ptr, "image height too large for row-pointer allocation");
row_pointers = (png_byte **)
png_calloc (png_ptr, height * sizeof (png_byte *));
png_set_rows (png_ptr, info_ptr, row_pointers);
Expand Down