add read loops to heif and ppm as well
We were not looping on vips_source_read() in these loaders, so they could fail when reading from very slow pipes. See https://github.com/kleisauke/net-vips/issues/101
This commit is contained in:
parent
c0102c5814
commit
ff450497ff
@ -963,12 +963,16 @@ vips_foreign_load_heif_read( void *data, size_t size, void *userdata )
|
|||||||
{
|
{
|
||||||
VipsForeignLoadHeif *heif = (VipsForeignLoadHeif *) userdata;
|
VipsForeignLoadHeif *heif = (VipsForeignLoadHeif *) userdata;
|
||||||
|
|
||||||
|
while( size > 0 ) {
|
||||||
gint64 result;
|
gint64 result;
|
||||||
|
|
||||||
result = vips_source_read( heif->source, data, size );
|
result = vips_source_read( heif->source, data, size );
|
||||||
if( result < 0 )
|
if( result <= 0 )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
|
size -= result;
|
||||||
|
}
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,14 +458,22 @@ vips_foreign_load_ppm_generate_binary( VipsRegion *or,
|
|||||||
for( y = 0; y < r->height; y++ ) {
|
for( y = 0; y < r->height; y++ ) {
|
||||||
VipsPel *q = VIPS_REGION_ADDR( or, 0, r->top + y );
|
VipsPel *q = VIPS_REGION_ADDR( or, 0, r->top + y );
|
||||||
|
|
||||||
|
size_t n_bytes;
|
||||||
|
|
||||||
|
n_bytes = sizeof_line;
|
||||||
|
while( n_bytes > 0 ) {
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
|
|
||||||
bytes_read = vips_source_read( ppm->source, q, sizeof_line );
|
bytes_read = vips_source_read( ppm->source,
|
||||||
if( bytes_read != sizeof_line ) {
|
q, sizeof_line );
|
||||||
|
if( bytes_read == 0 ) {
|
||||||
vips_error( class->nickname,
|
vips_error( class->nickname,
|
||||||
"%s", _( "file truncated" ) );
|
"%s", _( "file truncated" ) );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n_bytes -= bytes_read;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
Loading…
Reference in New Issue
Block a user