summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-02-18 15:27:13 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2017-03-01 11:16:40 +0100
commit3b4547c26b788d8f2e0cb3ff4c30b93f90f6b149 (patch)
tree4f0220b5675c4f13fad67c8a59173dad37ba9220
parentb5c57df05f075a87f43e97091ea3b10b5dc69b7f (diff)
downloadvala-3b4547c26b788d8f2e0cb3ff4c30b93f90f6b149.tar.gz
dbus: Move send_message() call before _error label
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 move the DBus reply before the _error label. https://bugzilla.gnome.org/show_bug.cgi?id=778540
-rw-r--r--codegen/valagdbusservermodule.vala38
1 files changed, 19 insertions, 19 deletions
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 56b765781..8f74aadb6 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -341,6 +341,25 @@ public class Vala.GDBusServerModule : GDBusClientModule {
ccode.add_expression (ccall);
}
+ if (!no_reply && (!m.coroutine || ready)) {
+ 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 (new CCodeConstant ("G_DBUS_SEND_MESSAGE_FLAGS_NONE"));
+ return_value.add_argument (new CCodeConstant ("NULL"));
+ return_value.add_argument (new CCodeConstant ("NULL"));
+ ccode.add_expression (return_value);
+
+ // free invocation like g_dbus_method_invocation_return_*
+ var unref_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
+ unref_call.add_argument (new CCodeIdentifier ("invocation"));
+ ccode.add_expression (unref_call);
+
+ unref_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
+ unref_call.add_argument (new CCodeIdentifier ("_reply_message"));
+ ccode.add_expression (unref_call);
+ }
+
if (need_goto_label) {
ccode.add_label ("_error");
}
@@ -368,25 +387,6 @@ public class Vala.GDBusServerModule : GDBusClientModule {
}
}
- if (!no_reply && (!m.coroutine || ready)) {
- 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 (new CCodeConstant ("G_DBUS_SEND_MESSAGE_FLAGS_NONE"));
- return_value.add_argument (new CCodeConstant ("NULL"));
- return_value.add_argument (new CCodeConstant ("NULL"));
- ccode.add_expression (return_value);
-
- // free invocation like g_dbus_method_invocation_return_*
- var unref_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
- unref_call.add_argument (new CCodeIdentifier ("invocation"));
- ccode.add_expression (unref_call);
-
- unref_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
- unref_call.add_argument (new CCodeIdentifier ("_reply_message"));
- ccode.add_expression (unref_call);
- }
-
pop_function ();
cfile.add_function_declaration (function);