png: add setjmp() to detect libpng internal error

This commit is contained in:
Kumataro 2025-09-05 11:30:48 +09:00
parent 6d889ee74c
commit d9572861d1

View File

@ -434,6 +434,9 @@ bool PngDecoder::readData( Mat& img )
if (!processing_start((void*)&frameRaw, mat_cur))
return false;
// See https://github.com/opencv/opencv/issues/27744
if( setjmp( png_jmpbuf ( m_png_ptr ) ) == 0 )
{
while (true)
{
id = read_chunk(chunk);
@ -567,6 +570,12 @@ bool PngDecoder::readData( Mat& img )
}
return false;
}
else
{
// libpng internal error is detected.
return false;
}
}
volatile bool result = false;
bool color = img.channels() > 1;