mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #26748 from vrabaud:png_leak
Fix remaining bugs in PNG reader
This commit is contained in:
commit
1e31f8047d
@ -339,6 +339,10 @@ bool PngDecoder::readHeader()
|
|||||||
png_bytep trans;
|
png_bytep trans;
|
||||||
png_color_16p trans_values;
|
png_color_16p trans_values;
|
||||||
|
|
||||||
|
// Free chunk in case png_read_info uses longjmp.
|
||||||
|
chunk.p.clear();
|
||||||
|
chunk.p.shrink_to_fit();
|
||||||
|
|
||||||
png_read_info( png_ptr, info_ptr );
|
png_read_info( png_ptr, info_ptr );
|
||||||
png_get_IHDR(png_ptr, info_ptr, &wdth, &hght,
|
png_get_IHDR(png_ptr, info_ptr, &wdth, &hght,
|
||||||
&bit_depth, &color_type, 0, 0, 0);
|
&bit_depth, &color_type, 0, 0, 0);
|
||||||
@ -703,6 +707,7 @@ uint32_t PngDecoder::read_chunk(Chunk& chunk)
|
|||||||
if (size > PNG_USER_CHUNK_MALLOC_MAX)
|
if (size > PNG_USER_CHUNK_MALLOC_MAX)
|
||||||
{
|
{
|
||||||
CV_LOG_WARNING(NULL, "chunk data is too large");
|
CV_LOG_WARNING(NULL, "chunk data is too large");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
chunk.p.resize(size);
|
chunk.p.resize(size);
|
||||||
memcpy(chunk.p.data(), len, 4);
|
memcpy(chunk.p.data(), len, 4);
|
||||||
|
Loading…
Reference in New Issue
Block a user