summaryrefslogtreecommitdiff
path: root/codegen/valagdbusclientmodule.vala
diff options
context:
space:
mode:
authormrmacete <mrmacete@protonmail.ch>2017-02-21 15:34:43 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2017-02-21 15:52:12 +0100
commitfc8a6ac1de1e162bf817fee704f15e38383b755e (patch)
treedb85141f9401c174a0a9c1f2a937fafd1720114e /codegen/valagdbusclientmodule.vala
parenta3b510c957d8c925c72fee13cd8edc8d00607dd3 (diff)
downloadvala-fc8a6ac1de1e162bf817fee704f15e38383b755e.tar.gz
gdbus: Fix memleak using g_task_propagate_pointer
https://bugzilla.gnome.org/show_bug.cgi?id=778993
Diffstat (limited to 'codegen/valagdbusclientmodule.vala')
-rw-r--r--codegen/valagdbusclientmodule.vala10
1 files changed, 9 insertions, 1 deletions
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index ac45b58cd..a0151f6e3 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -729,13 +729,21 @@ public class Vala.GDBusClientModule : GDBusModule {
// unwrap async result
if (context.require_glib_version (2, 36)) {
+ ccode.add_declaration ("GAsyncResult", new CCodeVariableDeclarator ("*_inner_res"));
+
var inner_res = new CCodeFunctionCall (new CCodeIdentifier ("g_task_propagate_pointer"));
inner_res.add_argument (new CCodeCastExpression (new CCodeIdentifier ("_res_"), "GTask *"));
inner_res.add_argument (new CCodeConstant ("NULL"));
- ccall.add_argument (inner_res);
+ ccode.add_assignment (new CCodeIdentifier ("_inner_res"), inner_res);
+ ccall.add_argument (new CCodeIdentifier ("_inner_res"));
ccall.add_argument (new CCodeConstant ("error"));
ccode.add_assignment (new CCodeIdentifier ("_reply_message"), ccall);
+
+ // _inner_res is guaranteed to be non-NULL, so just unref it
+ var unref_inner_res = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
+ unref_inner_res.add_argument (new CCodeIdentifier ("_inner_res"));
+ ccode.add_expression (unref_inner_res);
} else {
var inner_res = new CCodeFunctionCall (new CCodeIdentifier ("g_simple_async_result_get_op_res_gpointer"));
inner_res.add_argument (new CCodeCastExpression (new CCodeIdentifier ("_res_"), "GSimpleAsyncResult *"));