From 285f6c74183818627c3babd1be1d3992c50012b7 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 14 Jan 2020 14:50:46 +0000 Subject: [PATCH] add casts for tiff seek To make our meaning clearer. libtiff uses uint64 for toff_t, with -1 cast to uint64 for an error indication, see: https://gitlab.com/libtiff/libtiff/blob/master/libtiff/tif_unix.c#L123 See also: https://github.com/kleisauke/net-vips/issues/53 --- libvips/foreign/tiff.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libvips/foreign/tiff.c b/libvips/foreign/tiff.c index b325dae2..82fc78d9 100644 --- a/libvips/foreign/tiff.c +++ b/libvips/foreign/tiff.c @@ -156,7 +156,9 @@ openin_source_seek( thandle_t st, toff_t position, int whence ) { VipsSource *source = VIPS_SOURCE( st ); - return( vips_source_seek( source, position, whence ) ); + /* toff_t is usually uint64, with -1 cast to uint64 to indicate error. + */ + return( (toff_t) vips_source_seek( source, position, whence ) ); } static int @@ -176,8 +178,10 @@ openin_source_length( thandle_t st ) /* libtiff will use this to get file size if tags like StripByteCounts * are missing. + * + * toff_t is usually uint64, with -1 cast to uint64 to indicate error. */ - return( vips_source_length( source ) ); + return( (toff_t) vips_source_length( source ) ); } static int