From fef024061f4642d8cf9033ca0df29d0c9974b1be Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 14 Nov 2021 04:09:23 +0000 Subject: [PATCH] layout fixes for tga sniff --- libvips/foreign/magick.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/libvips/foreign/magick.c b/libvips/foreign/magick.c index 75ef879d..a942d7e7 100644 --- a/libvips/foreign/magick.c +++ b/libvips/foreign/magick.c @@ -52,14 +52,15 @@ #if defined(HAVE_MAGICK6) || defined(HAVE_MAGICK7) -/* ImageMagick can't detect some formats, like ICO and TGA, by examining the contents -- - * ico.c and tga.c simply do not have recognisers. +/* ImageMagick can't detect some formats, like ICO and TGA, by examining the + * contents -- ico.c and tga.c simply do not have recognisers. * * For these formats, do the detection ourselves. * Return an IM format specifier, or NULL to let IM do the detection. * - * For sniffing TGAs, we check that there is at least enough room for the header and that - * the preamble contains valid values: + * For sniffing TGAs, we check that there is at least enough room for the + * header and that the preamble contains valid values: + * * ----------------------------------------------------------- * |0x00 | 0-255 idlength, skip | * |0x01 | 0-1, color map present | @@ -80,16 +81,18 @@ magick_sniff( const unsigned char *bytes, size_t length ) bytes[2] == 1 && bytes[3] == 0 ) return( "ICO" ); - if( length >= 18 && - (bytes[1] == 0 || bytes[1] == 1) && ( - bytes[2] == 0 || - bytes[2] == 1 || - bytes[2] == 2 || - bytes[2] == 3 || - bytes[2] == 9 || - bytes[2] == 10 || - bytes[2] == 11) ) - return( "TGA" ); + + if( length >= 18 && + (bytes[1] == 0 || + bytes[1] == 1) && + (bytes[2] == 0 || + bytes[2] == 1 || + bytes[2] == 2 || + bytes[2] == 3 || + bytes[2] == 9 || + bytes[2] == 10 || + bytes[2] == 11) ) + return( "TGA" ); return( NULL ); }