]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gdbus: Initialize intermediate variables
authorCarlos Garnacho <carlosg@gnome.org>
Sun, 12 Feb 2017 22:08:12 +0000 (23:08 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 13 Feb 2017 06:54:25 +0000 (07:54 +0100)
Those may be left uninitialized after error handling paths are introduced,
so invalid data might be attempted to be freed later on.

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

codegen/valagdbusclientmodule.vala
codegen/valagdbusservermodule.vala

index 86d42595e1c6d2ea5b0bceaa6b3ec8da7e509947..6fdda8a50105b7a79d941dd5c13da1a38d9fe12a 100644 (file)
@@ -795,7 +795,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 
                                foreach (Parameter param in m.get_parameters ()) {
                                        if (param.direction == ParameterDirection.OUT) {
-                                               ccode.add_declaration (get_ccode_name (param.variable_type), new CCodeVariableDeclarator ("_vala_%s".printf (param.name)));
+                                               ccode.add_declaration (get_ccode_name (param.variable_type), new CCodeVariableDeclarator.zero ("_vala_%s".printf (param.name), default_value_for_type (param.variable_type, true)));
 
                                                var array_type = param.variable_type as ArrayType;
 
@@ -834,7 +834,7 @@ public class Vala.GDBusClientModule : GDBusModule {
                                                var target = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result"));
                                                receive_dbus_value (m.return_type, new CCodeIdentifier ("_reply_message"), new CCodeIdentifier ("_reply_iter"), target, m);
                                        } else {
-                                               ccode.add_declaration (get_ccode_name (m.return_type), new CCodeVariableDeclarator ("_result"));
+                                               ccode.add_declaration (get_ccode_name (m.return_type), new CCodeVariableDeclarator.zero ("_result", default_value_for_type (m.return_type, true)));
 
                                                var array_type = m.return_type as ArrayType;
 
index 617df210b6defbe879af88861472c2fd31de3471..4a20a2d92f98a0de992b3c2cf6a9ca67d890a782 100644 (file)
@@ -237,7 +237,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
                                ccode.close ();
                        }
 
-                       ccode.add_declaration ("GDBusMessage*", new CCodeVariableDeclarator ("_reply_message"));
+                       ccode.add_declaration ("GDBusMessage*", new CCodeVariableDeclarator.zero ("_reply_message", new CCodeConstant ("NULL")));
 
                        var message_expr = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_method_invocation_get_message"));
                        message_expr.add_argument (new CCodeIdentifier ("invocation"));