summaryrefslogtreecommitdiff
path: root/tests/basic-types
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2016-09-16 16:54:21 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2016-09-16 17:03:49 +0200
commit2ee9d3f5e4af2e73b8bc5d26044ac40f68232b3d (patch)
tree4df9801efac207217d95e3a6c5db77aa17b76bc4 /tests/basic-types
parent3592f2113f30d7f379c000c76f93da8556f0be4f (diff)
downloadvala-2ee9d3f5e4af2e73b8bc5d26044ac40f68232b3d.tar.gz
vala: Don't force array-elements to be owned, unowned ones are supported
Passing an (unowned string) array literal to a function causes the array elements to be freed afterwards, even though they should not be. This causes the array elements to be double freed. While assigning the literal to an intermediate variable and passing that to the function masks this error of the ArrayCreationExpression. https://bugzilla.gnome.org/show_bug.cgi?id=761307
Diffstat (limited to 'tests/basic-types')
-rw-r--r--tests/basic-types/bug761307.vala12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/basic-types/bug761307.vala b/tests/basic-types/bug761307.vala
new file mode 100644
index 000000000..5e90dcfa3
--- /dev/null
+++ b/tests/basic-types/bug761307.vala
@@ -0,0 +1,12 @@
+void bar ((unowned string)[] str) {
+}
+
+void foo () {
+ unowned string s1 = "ABC", s2 = "CDE";
+ bar ({s1, s2});
+ var s3 = "%s%s".printf (s1, s2);
+}
+
+void main () {
+ foo ();
+}