Skip to content

Commit 4e612df

Browse files
authored
libpng: Cherry-pick pnggroup/libpng@7cecdca
1 parent 4a8b307 commit 4e612df

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

vendor/libpng/png.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,16 @@ png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)
108108
if (png_ptr == NULL)
109109
return NULL;
110110

111-
if (items >= (~(png_alloc_size_t)0)/size)
111+
/* This check against overflow is vestigial, dating back from
112+
* the old times when png_zalloc used to be an exported function.
113+
* We're still keeping it here for now, as an extra-cautious
114+
* prevention against programming errors inside zlib, although it
115+
* should rather be a debug-time assertion instead.
116+
*/
117+
if (size != 0 && items >= (~(png_alloc_size_t)0) / size)
112118
{
113-
png_warning (png_voidcast(png_structrp, png_ptr),
114-
"Potential overflow in png_zalloc()");
119+
png_warning(png_voidcast(png_structrp, png_ptr),
120+
"Potential overflow in png_zalloc()");
115121
return NULL;
116122
}
117123

0 commit comments

Comments
 (0)