]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gdbus: Ensure extracted data from the GVariant is freed on error
authorCarlos Garnacho <carlosg@gnome.org>
Sun, 12 Feb 2017 22:02:34 +0000 (23:02 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 13 Feb 2017 06:54:25 +0000 (07:54 +0100)
This will make extracted variables properly freed when extracting those
fails at some point.

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

codegen/valagdbusservermodule.vala

index 4a20a2d92f98a0de992b3c2cf6a9ca67d890a782..0df78c24c93159aa24e8ebc9b8d6a5133e0d90bc 100644 (file)
@@ -23,6 +23,7 @@
 public class Vala.GDBusServerModule : GDBusClientModule {
        string generate_dbus_wrapper (Method m, ObjectTypeSymbol sym, bool ready = false) {
                string wrapper_name = "_dbus_%s".printf (get_ccode_name (m));
+               bool need_goto_label = false;
 
                if (m.base_method != null) {
                        m = m.base_method;
@@ -142,7 +143,8 @@ public class Vala.GDBusServerModule : GDBusClientModule {
                                        return_error.add_argument (new CCodeIdentifier ("error"));
                                        ccode.add_expression (return_error);
 
-                                       ccode.add_return ();
+                                       ccode.add_goto ("_error");
+                                       need_goto_label = true;
 
                                        ccode.close ();
                                }
@@ -338,6 +340,10 @@ public class Vala.GDBusServerModule : GDBusClientModule {
                        ccode.add_expression (ccall);
                }
 
+               if (need_goto_label) {
+                       ccode.add_label ("_error");
+               }
+
                foreach (Parameter param in m.get_parameters ()) {
                        if ((param.direction == ParameterDirection.IN && !ready) ||
                            (param.direction == ParameterDirection.OUT && !no_reply && (!m.coroutine || ready))) {