]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Unref GLib.AsyncResult on uncaught errors in coroutines
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 28 Apr 2017 13:31:19 +0000 (15:31 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 30 Apr 2017 16:29:19 +0000 (18:29 +0200)
Ignoring the warning of uncaught error in async methods resulted in
leaking a reference to the scopes GLib.AsyncResult.

https://bugzilla.gnome.org/show_bug.cgi?id=641171

codegen/valagerrormodule.vala

index 041779bac24e7ddd704b72484723eeec41b0aa08..47056f17b387d7988f76a5397da7331ee9cf3cb1 100644 (file)
@@ -143,6 +143,10 @@ public class Vala.GErrorModule : CCodeDelegateModule {
                                ccode.add_return (new CCodeConstant ("NULL"));
                        }
                } else if (is_in_coroutine ()) {
+                       var async_result_expr = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_async_result");
+                       var unref = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
+                       unref.add_argument (async_result_expr);
+                       ccode.add_expression (unref);
                        ccode.add_return (new CCodeConstant ("FALSE"));
                } else if (current_return_type != null) {
                        return_default_value (current_return_type);