fix jpegload fail

we were only failing on libjpeg errors, but libjpeg treats very serious
things thaht we want to be able to catch (like truncated files) as warnings
... we must therefore error out if fail is set and libjpeg issues a warning

see https://github.com/lovell/sharp/issues/793
This commit is contained in:
John Cupitt 2017-08-29 09:49:38 +01:00
parent f2576003b7
commit e2c83fe4bd
3 changed files with 27 additions and 7 deletions

View File

@ -1,3 +1,6 @@
29/8/17 started 8.5.9
- make --fail stop jpeg read on any libjpeg warning, thanks @mceachen
2/8/17 started 8.5.8
- fix transparency detection in merge, thanks Haida
- define env var VIPS_WARNING to hide warning messages

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below
AC_INIT([vips], [8.5.8], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [8.5.9], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ(2.62)
@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [8])
m4_define([vips_minor_version], [5])
m4_define([vips_micro_version], [8])
m4_define([vips_micro_version], [9])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date`
# binary interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=49
LIBRARY_REVISION=7
LIBRARY_REVISION=8
LIBRARY_AGE=7
# patched into include/vips/version.h

View File

@ -87,6 +87,10 @@
* - invalidate operation on read error
* 12/5/17
* - fail aborts on error, not warning
* 29/8/17
* - revert previous warning change: libvips reports serious corruption,
* like a truncated file, as a warning and we need to be able to catch
* that
*/
/*
@ -150,7 +154,7 @@ typedef struct _ReadJpeg {
*/
int shrink;
/* Fail on errors.
/* Fail on warning.
*/
gboolean fail;
@ -571,10 +575,23 @@ read_jpeg_generate( VipsRegion *or,
printf( "read_jpeg_generate: lonjmp() exit\n" );
#endif /*DEBUG*/
if( jpeg->fail )
return( -1 );
return( -1 );
}
return( 0 );
/* If --fail is set, we make read fail on any warnings. This
* will stop on any errors from the previous jpeg_read_scanlines().
* libjpeg warnings are used for serious image corruption, like
* truncated files.
*/
if( jpeg->eman.pub.num_warnings > 0 &&
jpeg->fail ) {
VIPS_GATE_STOP( "read_jpeg_generate: work" );
/* Only fail once.
*/
jpeg->eman.pub.num_warnings = 0;
return( -1 );
}
for( y = 0; y < r->height; y++ ) {