summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/params.c11
1 files changed, 8 insertions, 3 deletions
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);
     }
 }