From 640994b64a26ef45676266bc32799fe18ef3f9b1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 20 Mar 2019 17:32:44 +0000 Subject: [PATCH] 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 --- libvips/iofuncs/image.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 2116f222..fd80f0e0 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -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 ); } /**