[vala/wip/bug778540: 2/2] dbus: Account for _reply_message being NULL in error paths
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/bug778540: 2/2] dbus: Account for _reply_message being NULL in error paths
- Date: Mon, 6 Mar 2017 10:19:17 +0000 (UTC)
commit f0cec6a38b8350171f374add3448133fb9c5b734
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Feb 18 15:27:13 2017 +0100
dbus: Account for _reply_message being NULL in error paths
Commit 09e6818d01 changed dbus server paths so requests fell back
to freeing allocated memory on errors. However certain kinds of
dbus replies issue a final g_dbus_connection_send_message() there.
In case of errors, _reply_message will be NULL, and the error paths
would have already issued g_dbus_method_invocation_return_gerror(),
so the g_dbus_connection_send_message() call is both unnecessary and
warns on the NULL argument. So add a NULL check for these cases.
https://bugzilla.gnome.org/show_bug.cgi?id=778540
codegen/valagdbusservermodule.vala | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index e3cbc6e..a51e701 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -369,9 +369,13 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
if (!no_reply && (!m.coroutine || ready)) {
+ var reply_message = new CCodeIdentifier ("_reply_message");
+ var expr = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, reply_message,
new CCodeConstant ("NULL"));
+ ccode.open_if (expr);
+
var return_value = new CCodeFunctionCall (new CCodeIdentifier
("g_dbus_connection_send_message"));
return_value.add_argument (connection);
- return_value.add_argument (new CCodeIdentifier ("_reply_message"));
+ return_value.add_argument (reply_message);
return_value.add_argument (new CCodeConstant ("G_DBUS_SEND_MESSAGE_FLAGS_NONE"));
return_value.add_argument (new CCodeConstant ("NULL"));
return_value.add_argument (new CCodeConstant ("NULL"));
@@ -383,8 +387,10 @@ public class Vala.GDBusServerModule : GDBusClientModule {
ccode.add_expression (unref_call);
unref_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
- unref_call.add_argument (new CCodeIdentifier ("_reply_message"));
+ unref_call.add_argument (reply_message);
ccode.add_expression (unref_call);
+
+ ccode.close ();
}
pop_function ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]