]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use copies of error_variable of catch-clauses for nested usage 765c39c73c3096dd1de984db023763ec13448ef5
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 6 Jun 2018 21:22:41 +0000 (23:22 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 14 Jan 2019 12:18:45 +0000 (13:18 +0100)
Calling visit_local_variable() multiple times on the same instance of a
LocalVariable causes issues.

codegen/valagerrormodule.vala

index d29d09ca10d0f307e56f8432d101bbae48ca86ec..c10826218b42d579887e843f5a2f4f92c4ce3ae5 100644 (file)
@@ -353,8 +353,12 @@ public class Vala.GErrorModule : CCodeDelegateModule {
                ccode.open_block ();
 
                if (clause.error_variable != null) {
-                       visit_local_variable (clause.error_variable);
-                       ccode.add_assignment (get_variable_cexpression (get_local_cname (clause.error_variable)), get_variable_cexpression ("_inner_error_"));
+                       // use a copy for possible nested usage
+                       var error_variable = new LocalVariable (clause.error_type.copy (), clause.variable_name);
+                       error_variable.active = true;
+                       error_variable.checked = true;
+                       visit_local_variable (error_variable);
+                       ccode.add_assignment (get_variable_cexpression (get_local_cname (error_variable)), get_variable_cexpression ("_inner_error_"));
                } else {
                        // error object is not used within catch statement, clear it
                        var cclear = new CCodeFunctionCall (new CCodeIdentifier ("g_clear_error"));