diff --git a/libvips/foreign/heifload.c b/libvips/foreign/heifload.c index 77e5f4bc..b4a14e56 100644 --- a/libvips/foreign/heifload.c +++ b/libvips/foreign/heifload.c @@ -963,11 +963,15 @@ vips_foreign_load_heif_read( void *data, size_t size, void *userdata ) { VipsForeignLoadHeif *heif = (VipsForeignLoadHeif *) userdata; - gint64 result; + while( size > 0 ) { + gint64 result; - result = vips_source_read( heif->source, data, size ); - if( result < 0 ) - return( -1 ); + result = vips_source_read( heif->source, data, size ); + if( result <= 0 ) + return( -1 ); + + size -= result; + } return( 0 ); } diff --git a/libvips/foreign/ppmload.c b/libvips/foreign/ppmload.c index bcc2e79a..77dfbb60 100644 --- a/libvips/foreign/ppmload.c +++ b/libvips/foreign/ppmload.c @@ -458,13 +458,21 @@ vips_foreign_load_ppm_generate_binary( VipsRegion *or, for( y = 0; y < r->height; y++ ) { VipsPel *q = VIPS_REGION_ADDR( or, 0, r->top + y ); - size_t bytes_read; + size_t n_bytes; - bytes_read = vips_source_read( ppm->source, q, sizeof_line ); - if( bytes_read != sizeof_line ) { - vips_error( class->nickname, - "%s", _( "file truncated" ) ); - return( -1 ); + n_bytes = sizeof_line; + while( n_bytes > 0 ) { + size_t bytes_read; + + bytes_read = vips_source_read( ppm->source, + q, sizeof_line ); + if( bytes_read == 0 ) { + vips_error( class->nickname, + "%s", _( "file truncated" ) ); + return( -1 ); + } + + n_bytes -= bytes_read; } }