signal error on EOF in jpegload more reliably

we were only warning on EOF in the read stub, even if fail was set

thanks bozaro

see https://github.com/libvips/libvips/issues/1946
This commit is contained in:
John Cupitt 2020-12-28 22:46:33 +00:00
parent 158e9e153a
commit 0982d0efbb
2 changed files with 7 additions and 1 deletions

View File

@ -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]

View File

@ -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;