guard against read zero bytes from libheif

This commit is contained in:
John Cupitt 2020-06-11 14:59:06 +01:00
parent 1e015654c3
commit b643bd9448
1 changed files with 6 additions and 2 deletions

View File

@ -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 );