summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/params.c11
2 files changed, 11 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 39ff8c7ec..4409e6ea2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-11-08  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* Sebastian: 39869: can transfer ownership of core of array when
+	assigning.
+
 	* 39867: Src/utils.c: cast to unsigned char to compare against
 	0x7f.
 
diff --git a/Src/params.c b/Src/params.c
index 330f22bb2..0894241b9 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2647,15 +2647,20 @@ setarrvalue(Value v, char **val)
 
 	for (i = 0; i < v->start; i++)
 	    *p++ = i < pre_assignment_length ? ztrdup(*q++) : ztrdup("");
-	for (r = val; *r;)
-	    *p++ = ztrdup(*r++);
+	for (r = val; *r;) {
+            /* Give away ownership of the string */
+	    *p++ = *r++;
+	}
 	if (v->end < pre_assignment_length)
 	    for (q = old + v->end; *q;)
 		*p++ = ztrdup(*q++);
 	*p = NULL;
 
 	v->pm->gsu.a->setfn(v->pm, new);
-	freearray(val);
+
+        /* Ownership of all strings has been
+         * given away, can plainly free */
+	free(val);
     }
 }