mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
Prevent imread from illegal memory access (Bug #2602)
The change is based on pull request #211.
This commit is contained in:
parent
7852b68c20
commit
1821d21f5b
@ -229,12 +229,16 @@ bool JpegDecoder::readHeader()
|
||||
if( m_f )
|
||||
jpeg_stdio_src( &state->cinfo, m_f );
|
||||
}
|
||||
jpeg_read_header( &state->cinfo, TRUE );
|
||||
|
||||
m_width = state->cinfo.image_width;
|
||||
m_height = state->cinfo.image_height;
|
||||
m_type = state->cinfo.num_components > 1 ? CV_8UC3 : CV_8UC1;
|
||||
result = true;
|
||||
if (state->cinfo.src != 0)
|
||||
{
|
||||
jpeg_read_header( &state->cinfo, TRUE );
|
||||
|
||||
m_width = state->cinfo.image_width;
|
||||
m_height = state->cinfo.image_height;
|
||||
m_type = state->cinfo.num_components > 1 ? CV_8UC3 : CV_8UC1;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( !result )
|
||||
|
Loading…
Reference in New Issue
Block a user