mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Document need to check for integer overflow when allocating a pixel
buffer for multiple rows in contrib/gregbook, contrib/pngminus, example.c, and in the manual (suggested by Jaeseung Choi).
This commit is contained in:
@@ -650,6 +650,13 @@ static void rpng2_win_init()
|
||||
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
||||
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
||||
|
||||
/* Guard against integer overflow */
|
||||
if (rpng2_info.height > ((size_t)(-1))/rowbytes) {
|
||||
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n",
|
||||
readpng2_cleanup(&rpng2_info);
|
||||
return;
|
||||
}
|
||||
|
||||
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
||||
if (!rpng2_info.image_data) {
|
||||
readpng2_cleanup(&rpng2_info);
|
||||
|
||||
Reference in New Issue
Block a user