avoid crash on missing copy function, fixes bug 471063.
authorMathias Hasselmann <mathias.hasselmann@gmx.de>
Tue, 28 Aug 2007 15:17:45 +0000 (15:17 +0000)
committerMathias Hasselmann <hasselmm@src.gnome.org>
Tue, 28 Aug 2007 15:17:45 +0000 (15:17 +0000)
2007-08-28  Mathias Hasselmann  <mathias.hasselmann@gmx.de>

* gobject/valacodegenerator.vala: avoid crash on missing copy
function, fixes bug 471063.

svn path=/trunk/; revision=520

ChangeLog
gobject/valacodegenerator.vala

index f7f5505..2ac0b3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-08-28  Mathias Hasselmann  <mathias.hasselmann@gmx.de>
+
+       * gobject/valacodegenerator.vala: avoid crash on missing copy
+       function, fixes bug 471063.
+
 2007-08-28  Marc-Andre Lureau  <marcandre.lureau@gmail.com>
 
        * doc/Makefile.am, doc/gidlgen.1, doc/vapigen.1:
index ef6f462..17067a8 100644 (file)
@@ -955,7 +955,11 @@ public class Vala.CodeGenerator : CodeVisitor {
                                        Report.error (type.data_type.source_reference, "The type `%s` doesn't contain a copy function".printf (type.data_type.get_full_name ()));
                                }
                        }
-                       return new CCodeIdentifier (dup_function);
+
+                       if (null != dup_function)
+                               return new CCodeIdentifier (dup_function);
+
+                       return null;
                } else if (type.type_parameter != null && current_type_symbol is Class) {
                        string func_name = "%s_dup_func".printf (type.type_parameter.name.down ());
                        return new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), func_name);
@@ -2245,7 +2249,13 @@ public class Vala.CodeGenerator : CodeVisitor {
                 * if static type of expr is non-null
                 */
                 
-               var ccall = new CCodeFunctionCall (get_dup_func_expression (expr.static_type));
+               var dupexpr = get_dup_func_expression (expr.static_type);
+
+               if (null == dupexpr) {
+                       return null;
+               }
+
+               var ccall = new CCodeFunctionCall (dupexpr);
 
                if (expr.static_type.non_null && expr.static_type.type_parameter == null) {
                        ccall.add_argument ((CCodeExpression) expr.ccodenode);