[vala/0.34] gdbus: Initialize intermediate variables



commit b2a2551de70a84d196af4b2c8915e8c2d4a448ac
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 12 23:08:12 2017 +0100

    gdbus: Initialize intermediate variables
    
    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 |    4 ++--
 codegen/valagdbusservermodule.vala |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 7ec2387..483264d 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -774,7 +774,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_" + 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;
 
@@ -813,7 +813,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;
 
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index daf2a62..ccef898 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -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"));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]