mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
pngdec: raise memory limit if needed
Some PNG input contain chunks larger than libpng's default memory-alloc limit (8M). Raise this limit reasonably if it looks like the input bitstream is larger than libpng's default limit. BUG=webp:497 Change-Id: I2c9fbed727424042444b82cbf15e0781cefb38dc
This commit is contained in:
parent
8df77fb1b1
commit
8696147da4
@ -259,6 +259,12 @@ int ReadPNG(const uint8_t* const data, size_t data_size,
|
|||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it looks like the bitstream is going to need more memory than libpng's
|
||||||
|
// internal limit (default: 8M), try to (reasonably) raise it.
|
||||||
|
if (data_size > png_get_chunk_malloc_max(png) && data_size < (1u << 24)) {
|
||||||
|
png_set_chunk_malloc_max(png, data_size);
|
||||||
|
}
|
||||||
|
|
||||||
info = png_create_info_struct(png);
|
info = png_create_info_struct(png);
|
||||||
if (info == NULL) goto Error;
|
if (info == NULL) goto Error;
|
||||||
end_info = png_create_info_struct(png);
|
end_info = png_create_info_struct(png);
|
||||||
|
Loading…
Reference in New Issue
Block a user