fix memleak in jpegsave_buffer with some errors
under some error conditions, jpegsave_buffer could forget to release a half-built image
This commit is contained in:
parent
c98da89ac9
commit
7aa46b258a
@ -221,6 +221,7 @@ write_new( VipsImage *in )
|
|||||||
write->in = in;
|
write->in = in;
|
||||||
write->row_pointer = NULL;
|
write->row_pointer = NULL;
|
||||||
write->cinfo.err = jpeg_std_error( &write->eman.pub );
|
write->cinfo.err = jpeg_std_error( &write->eman.pub );
|
||||||
|
write->cinfo.dest = NULL;
|
||||||
write->eman.pub.error_exit = vips__new_error_exit;
|
write->eman.pub.error_exit = vips__new_error_exit;
|
||||||
write->eman.pub.output_message = vips__new_output_message;
|
write->eman.pub.output_message = vips__new_output_message;
|
||||||
write->eman.fp = NULL;
|
write->eman.fp = NULL;
|
||||||
@ -652,7 +653,7 @@ write_vips( Write *write, int qfac, const char *profile,
|
|||||||
if( setjmp( write->eman.jmp ) )
|
if( setjmp( write->eman.jmp ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
/* This should obly be called on a successful write.
|
/* This should only be called on a successful write.
|
||||||
*/
|
*/
|
||||||
jpeg_finish_compress( &write->cinfo );
|
jpeg_finish_compress( &write->cinfo );
|
||||||
|
|
||||||
@ -766,9 +767,12 @@ init_destination( j_compress_ptr cinfo )
|
|||||||
static void
|
static void
|
||||||
buf_destroy( j_compress_ptr cinfo )
|
buf_destroy( j_compress_ptr cinfo )
|
||||||
{
|
{
|
||||||
|
printf( "buf_destroy:\n" );
|
||||||
|
|
||||||
if( cinfo->dest ) {
|
if( cinfo->dest ) {
|
||||||
OutputBuffer *buf = (OutputBuffer *) cinfo->dest;
|
OutputBuffer *buf = (OutputBuffer *) cinfo->dest;
|
||||||
|
|
||||||
|
printf( "buf_destroy: destroying\n" );
|
||||||
vips_dbuf_destroy( &buf->dbuf );
|
vips_dbuf_destroy( &buf->dbuf );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -848,8 +852,9 @@ vips__jpeg_write_buffer( VipsImage *in,
|
|||||||
/* Make jpeg compression object.
|
/* Make jpeg compression object.
|
||||||
*/
|
*/
|
||||||
if( setjmp( write->eman.jmp ) ) {
|
if( setjmp( write->eman.jmp ) ) {
|
||||||
/* Here for longjmp() from new_error_exit() during setup.
|
/* Here for longjmp() during write_vips().
|
||||||
*/
|
*/
|
||||||
|
buf_destroy( &write->cinfo );
|
||||||
write_destroy( write );
|
write_destroy( write );
|
||||||
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
Loading…
Reference in New Issue
Block a user