Skip to content

Commit

Permalink
Merge pull request opencv#25864 from vrabaud:legacy
Browse files Browse the repository at this point in the history
Make sure all the lines of a JPEG are read opencv#25864

In case of corrupted JPEG, imread would still return a JPEG of the proper size (as indicated by the header) but with some uninitialized values. I do not have a short reproducer I can add as a test as this was found by our fuzzers.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
  • Loading branch information
vrabaud authored Jul 5, 2024
1 parent 94b7a2d commit dfbd18e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/imgcodecs/src/grfmt_jpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ bool JpegDecoder::readData( Mat& img )
for( int iy = 0 ; iy < m_height; iy ++ )
{
uchar* data = img.ptr<uchar>(iy);
jpeg_read_scanlines( cinfo, &data, 1 );
if (jpeg_read_scanlines( cinfo, &data, 1 ) != 1) return false;
}
}
else
Expand All @@ -510,7 +510,7 @@ bool JpegDecoder::readData( Mat& img )
for( int iy = 0 ; iy < m_height; iy ++ )
{
uchar* data = img.ptr<uchar>(iy);
jpeg_read_scanlines( cinfo, buffer, 1 );
if (jpeg_read_scanlines( cinfo, buffer, 1 ) != 1) return false;

if( color )
{
Expand Down

0 comments on commit dfbd18e

Please sign in to comment.