From daf075112d0744fd73d181c2959e5866e4881ab1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 9 Apr 2014 11:52:32 +0100 Subject: [PATCH] fix possible memleak fix tiny leak if output options failed --- TODO | 10 ---------- libvips/iofuncs/operation.c | 11 +++++++++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 523113c2..8031fceb 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,3 @@ -- try: - - $ vips system "vips add %s %s %s" --in "k2.jpg k4.jpg" \ - --out-format "%s.tif" --out x.v --log - memory: high-water mark 9.37 MB - "" - memory: high-water mark 27.89 MB - $ - - but x.v does not appear - can we use postbuild elsewhere? look at use of "preclose" / "written", etc. diff --git a/libvips/iofuncs/operation.c b/libvips/iofuncs/operation.c index 4f37ad2c..932c9036 100644 --- a/libvips/iofuncs/operation.c +++ b/libvips/iofuncs/operation.c @@ -793,10 +793,14 @@ vips_call_option_output( VipsObject *object, result = vips_object_get_argument_to_string( object, g_param_spec_get_name( pspec ), output->value ); + return( result ); +} + +static void +vips_call_option_output_free( VipsObject *object, VipsCallOptionOutput *output ) +{ VIPS_FREE( output->value ); g_free( output ); - - return( result ); } static gboolean @@ -866,6 +870,9 @@ vips_call_options_set( const gchar *option_name, const gchar *value, g_signal_connect( operation, "postbuild", G_CALLBACK( vips_call_option_output ), output ); + g_signal_connect( operation, "close", + G_CALLBACK( vips_call_option_output_free ), + output ); } return( TRUE );