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
1 changed files with 11 additions and 6 deletions

View File

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