From b643bd9448a8c4016eaf91ca7bfd2d34573bc4d0 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 11 Jun 2020 14:59:06 +0100 Subject: [PATCH] guard against read zero bytes from libheif --- libvips/foreign/heifload.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libvips/foreign/heifload.c b/libvips/foreign/heifload.c index aaa09005..258de9a4 100644 --- a/libvips/foreign/heifload.c +++ b/libvips/foreign/heifload.c @@ -873,9 +873,13 @@ vips_foreign_load_heif_read( void *data, size_t size, void *userdata ) gint64 result; result = vips_source_read( heif->source, data, size ); - /* On EOF, make a note of the file length. + /* On EOF, make a note of the file length. + * + * libheif can sometimes ask for zero bytes, be careful not to + * interpret that as EOF. */ - if( result == 0 && + if( size > 0 && + result == 0 && heif->length == -1 ) result = heif->length = vips_source_seek( heif->source, 0L, SEEK_CUR );