Ensure that streams are properly read in spngload

This commit is contained in:
Kleis Auke Wolthuizen 2020-11-11 20:14:02 +01:00 committed by John Cupitt
parent 6894159ad5
commit 0a91e2d8c7

View File

@ -94,13 +94,18 @@ vips_foreign_load_png_stream( spng_ctx *ctx, void *user,
{
VipsSource *source = VIPS_SOURCE( user );
while( length > 0 ) {
gint64 bytes_read;
bytes_read = vips_source_read( source, dest, length );
if( bytes_read < 0 )
return( SPNG_IO_ERROR );
if( bytes_read < length )
return( SPNG_IO_EOF);
if( bytes_read == 0 )
return( SPNG_IO_EOF );
dest += bytes_read;
length -= bytes_read;
}
return( 0 );
}