From db6e6a00761d62fa85ff68af8034a48b1b910d6a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 25 Aug 2019 11:29:37 +0100 Subject: [PATCH] catch /0 in exif read --- libvips/foreign/exif.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libvips/foreign/exif.c b/libvips/foreign/exif.c index 759e0fdc..971186e0 100644 --- a/libvips/foreign/exif.c +++ b/libvips/foreign/exif.c @@ -237,14 +237,25 @@ vips_exif_get_double( ExifData *ed, { ExifRational rv; ExifSRational srv; + double value; - if( !vips_exif_get_rational( ed, entry, component, &rv ) ) - *out = (double) rv.numerator / rv.denominator; - else if( !vips_exif_get_srational( ed, entry, component, &srv ) ) - *out = (double) srv.numerator / srv.denominator; + if( !vips_exif_get_rational( ed, entry, component, &rv ) ) { + if( rv.denominator == 0 ) + value = 0; + else + value = (double) rv.numerator / rv.denominator; + } + else if( !vips_exif_get_srational( ed, entry, component, &srv ) ) { + if( srv.denominator == 0 ) + value = 0; + else + value = (double) srv.numerator / srv.denominator; + } else return( -1 ); + *out = value; + return( 0 ); }