From: Carlos Garnacho Date: Sun, 12 Feb 2017 22:02:34 +0000 (+0100) Subject: gdbus: Ensure extracted data from the GVariant is freed on error X-Git-Tag: 0.35.4~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09e6818d01e;p=thirdparty%2Fvala.git gdbus: Ensure extracted data from the GVariant is freed on error This will make extracted variables properly freed when extracting those fails at some point. https://bugzilla.gnome.org/show_bug.cgi?id=778540 --- diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala index 4a20a2d92..0df78c24c 100644 --- a/codegen/valagdbusservermodule.vala +++ b/codegen/valagdbusservermodule.vala @@ -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))) {