1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-01 09:41:44 +02:00

39869: can transfer ownership of core of array when assigning

This commit is contained in:
Sebastian Gniazdowski 2016-11-08 02:27:04 -08:00 committed by Peter Stephenson
parent 39521515c3
commit 68a576bc55
2 changed files with 11 additions and 3 deletions

View file

@ -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.

View file

@ -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);
}
}