Merge pull request #212 from taka-no-me/fix_2602

Prevent imread from illegal memory access (Bug #2602)
This commit is contained in:
Andrey Kamaev 2012-12-10 11:48:28 -08:00
commit 60ad505a63

View File

@ -229,12 +229,16 @@ bool JpegDecoder::readHeader()
if( m_f ) if( m_f )
jpeg_stdio_src( &state->cinfo, m_f ); jpeg_stdio_src( &state->cinfo, m_f );
} }
jpeg_read_header( &state->cinfo, TRUE );
m_width = state->cinfo.image_width; if (state->cinfo.src != 0)
m_height = state->cinfo.image_height; {
m_type = state->cinfo.num_components > 1 ? CV_8UC3 : CV_8UC1; jpeg_read_header( &state->cinfo, TRUE );
result = 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 ) if( !result )