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

Prevent imread from illegal memory access (Bug #2602)
pull/184/merge
Andrey Kamaev 12 years ago
commit 60ad505a63
  1. 4
      modules/highgui/src/grfmt_jpeg.cpp

@ -229,6 +229,9 @@ bool JpegDecoder::readHeader()
if( m_f ) if( m_f )
jpeg_stdio_src( &state->cinfo, m_f ); jpeg_stdio_src( &state->cinfo, m_f );
} }
if (state->cinfo.src != 0)
{
jpeg_read_header( &state->cinfo, TRUE ); jpeg_read_header( &state->cinfo, TRUE );
m_width = state->cinfo.image_width; m_width = state->cinfo.image_width;
@ -236,6 +239,7 @@ bool JpegDecoder::readHeader()
m_type = state->cinfo.num_components > 1 ? CV_8UC3 : CV_8UC1; m_type = state->cinfo.num_components > 1 ? CV_8UC3 : CV_8UC1;
result = true; result = true;
} }
}
if( !result ) if( !result )
close(); close();

Loading…
Cancel
Save