From edbe0c99cc078ff15d5c8843e7c4cbc6b45e62b8 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 22 Jun 2011 13:51:26 +0100 Subject: [PATCH] fix strange warning with binary ppm load Binary ppm load would always warn about "file too long". The image size prediction was missing the image header size. --- libvips/iofuncs/image.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index c304ab81..07eaaf05 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -903,7 +903,9 @@ vips_image_build( VipsObject *object ) VipsImage *image = VIPS_IMAGE( object ); const char *filename = image->filename; const char *mode = image->mode; + VipsFormatClass *format; + size_t sizeof_image; VIPS_DEBUG_MSG( "vips_image_build: %p\n", image ); @@ -1008,7 +1010,9 @@ vips_image_build( VipsObject *object ) /* Very common, so a special message. */ - if( image->file_length < VIPS_IMAGE_SIZEOF_IMAGE( image ) ) { + sizeof_image = VIPS_IMAGE_SIZEOF_IMAGE( image ) + + image->sizeof_header; + if( image->file_length < sizeof_image ) { vips_error( "VipsImage", _( "unable to open \"%s\", file too short" ), image->filename ); @@ -1018,7 +1022,7 @@ vips_image_build( VipsObject *object ) /* Just weird. Only print a warning for this, since we should * still be able to process it without coredumps. */ - if( image->file_length > VIPS_IMAGE_SIZEOF_IMAGE( image ) ) + if( image->file_length > sizeof_image ) vips_warn( "VipsImage", _( "%s is longer than expected" ), image->filename );