From: Jürg Billeter Date: Wed, 3 Mar 2010 13:10:35 +0000 (+0100) Subject: Fix memory management of captured variables in error handlers X-Git-Tag: 0.8.0~237 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab6c34b398cb5f4cf177ffc48afa82ed9dc2ff4a;p=thirdparty%2Fvala.git Fix memory management of captured variables in error handlers Fixes bug 611624. --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 287e494c7..52b0eeffe 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -3163,13 +3163,21 @@ internal class Vala.CCodeBaseModule : CCodeModule { var local_vars = b.get_local_variables (); foreach (LocalVariable local in local_vars) { - if (local.active && !local.floating && requires_destroy (local.variable_type)) { + if (local.active && !local.floating && !local.captured && requires_destroy (local.variable_type)) { var ma = new MemberAccess.simple (local.name); ma.symbol_reference = local; cfrag.append (new CCodeExpressionStatement (get_unref_expression (get_variable_cexpression (local.name), local.variable_type, ma))); } } + if (b.captured) { + int block_id = get_block_id (b); + + var data_unref = new CCodeFunctionCall (new CCodeIdentifier ("block%d_data_unref".printf (block_id))); + data_unref.add_argument (get_variable_cexpression ("_data%d_".printf (block_id))); + cfrag.append (new CCodeExpressionStatement (data_unref)); + } + if (sym == current_try.body) { return; }