From 7aed4c04e7b6f060764ba3daf5adafc4a85edcf2 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 21 Nov 2017 18:06:49 +0000 Subject: [PATCH] fix gif-loop metadata thanks Christian Stocker --- libvips/foreign/gifload.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/libvips/foreign/gifload.c b/libvips/foreign/gifload.c index 9364ba4b..32034b6e 100644 --- a/libvips/foreign/gifload.c +++ b/libvips/foreign/gifload.c @@ -579,10 +579,24 @@ vips_foreign_load_gif_page( VipsForeignLoadGif *gif, VipsImage *out ) if( ext_code == APPLICATION_EXT_FUNC_CODE && extension && extension[0] == 11 && - /* Then 'NETSCAPE2.0', then */ - extension[12] == 3 && - extension[13] == 1 ) - gif->loop = extension[14] | (extension[15] << 8); + vips_isprefix( "NETSCAPE2.0", + (const char *) (extension + 1) ) ) { + while( extension != NULL ) { + if( DGifGetExtensionNext( gif->file, + &extension ) == GIF_ERROR ) { + vips_foreign_load_gif_error( + gif ); + return( -1 ); + } + + if( extension && + extension[0] == 3 && + extension[1] == 1 ) { + gif->loop = extension[2] | + (extension[3] << 8); + } + } + } while( extension != NULL ) { if( DGifGetExtensionNext( gif->file,