[vala] Fix crash due to incorrect copy of attribute list



commit 1f5a97f048b572187608b5411f060f4bd7931cba
Author: JÃrg Billeter <j bitron ch>
Date:   Tue Jun 26 08:34:22 2012 +0200

    Fix crash due to incorrect copy of attribute list
    
    Fixes bug 678824.

 vala/valagirparser.vala |   10 ++++++++--
 vala/valaparameter.vala |   10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index a09e742..f7c5dd3 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1,6 +1,6 @@
 /* valagirparser.vala
  *
- * Copyright (C) 2008-2010  JÃrg Billeter
+ * Copyright (C) 2008-2012  JÃrg Billeter
  * Copyright (C) 2011  Luca Bruno
  *
  * This library is free software; you can redistribute it and/or
@@ -3459,7 +3459,13 @@ public class Vala.GirParser : CodeVisitor {
 				method.external = true;
 				method.coroutine = true;
 				method.has_construct_function = finish_method.has_construct_function;
-				method.attributes = m.attributes.copy ();
+
+				// cannot use List.copy()
+				// as it returns a list of unowned elements
+				foreach (Attribute a in m.attributes) {
+					method.attributes.append (a);
+				}
+
 				method.set_attribute_string ("CCode", "cname", node.get_cname ());
 				if (finish_method_base == "new") {
 					method.name = null;
diff --git a/vala/valaparameter.vala b/vala/valaparameter.vala
index 22fe0c8..b089dde 100644
--- a/vala/valaparameter.vala
+++ b/vala/valaparameter.vala
@@ -1,6 +1,6 @@
 /* valaparameter.vala
  *
- * Copyright (C) 2006-2011  JÃrg Billeter
+ * Copyright (C) 2006-2012  JÃrg Billeter
  * Copyright (C) 2006-2008  Raffaele Sandrini
  *
  * This library is free software; you can redistribute it and/or
@@ -101,7 +101,13 @@ public class Vala.Parameter : Variable {
 			result.params_array = params_array;
 			result.direction = this.direction;
 			result.initializer = this.initializer;
-			result.attributes = this.attributes.copy ();
+
+			// cannot use List.copy()
+			// as it returns a list of unowned elements
+			foreach (Attribute a in this.attributes) {
+				result.attributes.append (a);
+			}
+
 			return result;
 		} else {
 			return new Parameter.with_ellipsis ();



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