From b03ad51ae36586f1925c2c72d32972ddae57d105 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 7 May 2016 21:01:04 +0100 Subject: [PATCH 1/3] oops, fix error reporting from giflib --- libvips/foreign/gifload.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/libvips/foreign/gifload.c b/libvips/foreign/gifload.c index 202ad674..2481526d 100644 --- a/libvips/foreign/gifload.c +++ b/libvips/foreign/gifload.c @@ -153,15 +153,33 @@ vips_foreign_load_gif_errstr( int error_code ) #endif /*HAVE_GIFLIB_5*/ } +static void +vips_foreign_load_gif_error_vips( VipsForeignLoadGif *gif, int error ) +{ + VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( gif ); + + const char *message; + + if( (message = vips_foreign_load_gif_errstr( gif->file->Error )) ) + vips_error( class->nickname, "%s", message ); +} + static void vips_foreign_load_gif_error( VipsForeignLoadGif *gif ) { + int error; + + error = 0; + #ifdef HAVE_GIFLIB_5 if( gif->file ) - vips_foreign_load_gif_errstr( gif->file->Error ); + error = gif->file->Error; #else - vips_foreign_load_gif_errstr( GifLastError() ); + error = GifLastError(); #endif + + if( error ) + vips_foreign_load_gif_error_vips( gif, error ); } static void @@ -172,13 +190,13 @@ vips_foreign_load_gif_close( VipsForeignLoadGif *gif ) int error; if( DGifCloseFile( gif->file, &error ) ) - vips_foreign_load_gif_errstr( error ); + vips_foreign_load_gif_error_vips( gif, error ); gif->file = NULL; } #else if( gif->file ) { if( DGifCloseFile( gif->file ) ) - vips_foreign_load_gif_errstr( GifLastError() ); + vips_foreign_load_gif_error_vips( gif, GifLastError() ); gif->file = NULL; } #endif @@ -194,13 +212,13 @@ vips_foreign_load_gif_open( VipsForeignLoadGif *gif, const char *filename ) int error; if( !(gif->file = DGifOpenFileName( filename, &error )) ) { - vips_foreign_load_gif_errstr( error ); + vips_foreign_load_gif_error_vips( gif, error ); return( -1 ); } } #else if( !(gif->file = DGifOpenFileName( filename )) ) { - vips_foreign_load_gif_errstr( GifLastError() ); + vips_foreign_load_gif_error_vips( gif, GifLastError() ); return( -1 ); } #endif @@ -218,13 +236,13 @@ vips_foreign_load_gif_open_buffer( VipsForeignLoadGif *gif, InputFunc read_fn ) int error; if( !(gif->file = DGifOpen( gif, read_fn, &error )) ) { - vips_foreign_load_gif_errstr( error ); + vips_foreign_load_gif_error_vips( gif, error ); return( -1 ); } } #else if( !(gif->file = DGifOpen( gif, read_fn )) ) { - vips_foreign_load_gif_errstr( GifLastError() ); + vips_foreign_load_gif_error_vips( gif, GifLastError() ); return( -1 ); } #endif @@ -435,7 +453,7 @@ vips_foreign_load_gif_load( VipsForeignLoad *load ) GifByteType *extension; int ext_code; - if( DGifGetRecordType( gif->file, &record) == GIF_ERROR ) { + if( DGifGetRecordType( gif->file, &record ) == GIF_ERROR ) { vips_foreign_load_gif_error( gif ); return( -1 ); } From 379b69fda881d487fbf117b7865876c30aa2bfef Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 8 May 2016 10:02:34 +0100 Subject: [PATCH 2/3] note on test suite failure --- TODO | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TODO b/TODO index cf0dcd7a..1f1a7cfc 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,10 @@ +- the gif tests in the suite sometimes fail with giflib5 because of an + uninitialized struct in giflib, see + + https://sourceforge.net/p/giflib/bugs/94/ + + sadly ubuntu 16.04 only comes with giflib5, and giflib5 is currently broken + - I like the new int mask creator in reducev, can we use it in im_vips2imask() as well? From f7a6a02ee8017f02cde73af6da4d319d64841b5a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 8 May 2016 11:02:21 +0100 Subject: [PATCH 3/3] fix giflib4 detection and a problem in giflib4 error handling --- ChangeLog | 1 + acinclude.m4 | 4 ++-- libvips/foreign/gifload.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cbb50c50..1b926428 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ - add giflib5 support - allow resize >1 on one axis, <1 on the other - vips_resize has an optional @kernel argument +- fix giflib4 detection [felixbuenemann] 29/1/16 started 8.3 - add vips_reduce*() ... a fast path for affine downsize diff --git a/acinclude.m4 b/acinclude.m4 index 4f17b2ab..d1bbc58f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -631,14 +631,14 @@ if test "$GIFLIB_LIBS" = ""; then INCLUDES="$GIFLIB_INCLUDES $INCLUDES" # Try the standard search path first - AC_TRY_LINK([#include ],[EGifSetGifVersion(0,0)], [ + AC_TRY_LINK([#include ],[DGifSlurp(0)], [ GIFLIB_LIBS="-lgif" ], [ # giflib is not in the standard search path, try $prefix LIBS="-L${prefix}/lib $LIBS" - AC_TRY_LINK([#include ],[EGifSetGifVersion(0,0)], [ + AC_TRY_LINK([#include ],[DGifSlurp(0)], [ GIFLIB_LIBS="-L${prefix}/lib -lgif" ], [ GIFLIB_LIBS=no diff --git a/libvips/foreign/gifload.c b/libvips/foreign/gifload.c index 2481526d..5fc317db 100644 --- a/libvips/foreign/gifload.c +++ b/libvips/foreign/gifload.c @@ -160,7 +160,7 @@ vips_foreign_load_gif_error_vips( VipsForeignLoadGif *gif, int error ) const char *message; - if( (message = vips_foreign_load_gif_errstr( gif->file->Error )) ) + if( (message = vips_foreign_load_gif_errstr( error )) ) vips_error( class->nickname, "%s", message ); }