From 4367ccb1772ce233807e285098dd3196b58cb098 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 6 Dec 2011 12:34:40 +0000 Subject: [PATCH] fix a refleak --- TODO | 35 ++++++++++++++++++++++++++++++----- libvips/iofuncs/object.c | 10 +++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 47fec3ad..a75f6d90 100644 --- a/TODO +++ b/TODO @@ -1,11 +1,38 @@ -- try: +- do we need vips_object_unref_outputs() in more places? check all calls to + _build() + + + + +- how about + + vips max add[babe.jpg,babe2.jpg] + + does that make any sense? + + vips copy add[babe.jpg,add[babe2.jpg,babe3.jpg]] sum.v + + - $ vips copy z.tif[page=12] babe.v - get a couple of leaked objects from the error - make im_tiff2vips.c into a stub +- what should we do? + + vips_image_new_from_file( "x.tif[page=12]" ); + + or maybe: + + vips_image_new_from_file( "x.tif", "page", 12, NULL ); + + or maybe neither? we'd like this to work though: + + header x.tif[page=12] + + object_new_from_string()? + + @@ -20,8 +47,6 @@ - "header fred.png" does not work, since header uses im_open() which uses VipsForeign -- "header x.tif[page=7]" does not work - diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 42b57a7c..ab284dd0 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -1280,16 +1280,20 @@ vips_object_set_argument_from_string( VipsObject *object, if( vips_cache_operation_build( (VipsOperation **) &new_object ) ) { + /* The build may have made some output objects before + * failing. + */ + vips_object_unref_outputs( new_object ); g_object_unref( new_object ); return( -1 ); } g_object_get( new_object, "out", &out, NULL ); - /* Getting @out will have upped it's count and we want to - * hold the only ref to it. + /* Getting @out will have upped its count so it'll be safe. + * We can junk all other outputs, */ - g_object_unref( out ); + vips_object_unref_outputs( new_object ); /* @out holds a ref to new_object, we can drop ours. */