diff --git a/ChangeLog b/ChangeLog index 83ead3ac..a6a90323 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - don't seek on bad file descriptors [kleisauke] - check for null memory sources [kleisauke] - revise ppmload, fixing a couple of small bugs +- signal error on EOF in jpegload more reliably [bozaro] 18/12/20 started 8.10.5 - fix potential /0 in animated webp load [lovell] diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index 08d8e7c3..6ac491df 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -212,6 +212,7 @@ typedef struct { /* Private stuff during read. */ + ReadJpeg *jpeg; VipsSource *source; unsigned char buf[SOURCE_BUFFER_SIZE]; @@ -248,7 +249,10 @@ source_fill_input_buffer( j_decompress_ptr cinfo ) src->pub.bytes_in_buffer = read; } else { - WARNMS( cinfo, JWRN_JPEG_EOF ); + if( src->jpeg->fail ) + ERREXIT( cinfo, JERR_INPUT_EOF ); + else + WARNMS( cinfo, JWRN_JPEG_EOF ); src->pub.next_input_byte = eoi_buffer; src->pub.bytes_in_buffer = 2; } @@ -294,6 +298,7 @@ readjpeg_open_input( ReadJpeg *jpeg ) sizeof( Source ) ); src = (Source *) cinfo->src; + src->jpeg = jpeg; src->source = jpeg->source; src->pub.init_source = source_init_source; src->pub.fill_input_buffer = source_fill_input_buffer;