fix a possible segv writing images to buffers

if write failed, vips_image_write_to_buffer() could segv

thanks @dbouron !

see https://github.com/libvips/libvips/issues/1248
This commit is contained in:
John Cupitt 2019-03-20 17:32:44 +00:00
parent 18c12fd66d
commit 640994b64a

View File

@ -2631,6 +2631,12 @@ vips_image_write_to_buffer( VipsImage *in,
ap, in, &blob );
va_end( ap );
if( result )
return( -1 );
*buf = NULL;
if( size )
*size = 0;
if( blob ) {
if( buf ) {
*buf = VIPS_AREA( blob )->data;
@ -2642,7 +2648,7 @@ vips_image_write_to_buffer( VipsImage *in,
vips_area_unref( VIPS_AREA( blob ) );
}
return( result );
return( 0 );
}
/**