From: Rico Tzschichholz Date: Thu, 29 Aug 2019 14:38:25 +0000 (+0200) Subject: codegen: Don't cause double-free due append_local_free() in uncaught-errors X-Git-Tag: 0.46.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=668345f49f0802081b3fcd606ec147cb8fc1e42f;p=thirdparty%2Fvala.git codegen: Don't cause double-free due append_local_free() in uncaught-errors See https://gitlab.gnome.org/GNOME/vala/issues/838 --- diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala index 2abd5a4ce..c64b410d5 100644 --- a/codegen/valagerrormodule.vala +++ b/codegen/valagerrormodule.vala @@ -117,9 +117,13 @@ public class Vala.GErrorModule : CCodeDelegateModule { } } - void uncaught_error_statement (CCodeExpression inner_error, bool unexpected = false) { + void uncaught_error_statement (CCodeExpression inner_error, bool unexpected = false, CodeNode? start_at = null) { // free local variables - append_local_free (current_symbol); + if (start_at is TryStatement) { + append_local_free (start_at.parent_node as Block); + } else { + append_local_free (current_symbol); + } var ccritical = new CCodeFunctionCall (new CCodeIdentifier ("g_critical")); ccritical.add_argument (new CCodeConstant (unexpected ? "\"file %s: line %d: unexpected error: %s (%s, %d)\"" : "\"file %s: line %d: uncaught error: %s (%s, %d)\"")); @@ -256,7 +260,7 @@ public class Vala.GErrorModule : CCodeDelegateModule { // as jump out of finally block is not supported } else { // should never happen with correct bindings - uncaught_error_statement (get_inner_error_cexpression (), true); + uncaught_error_statement (get_inner_error_cexpression (), true, current_try); } } else if (current_method != null && current_method.tree_can_fail) { // current method can fail, propagate error