sh: Fix memory leak when trying to set a read only variable.

MFC after:	1 week
This commit is contained in:
Jilles Tjoelker 2014-03-27 22:52:26 +00:00
parent cf321a51b1
commit 89d4f883a4

View File

@ -325,8 +325,11 @@ setvareq(char *s, int flags)
mklocal(s);
vp = find_var(s, &vpp, &nlen);
if (vp != NULL) {
if (vp->flags & VREADONLY)
if (vp->flags & VREADONLY) {
if ((flags & (VTEXTFIXED|VSTACK)) == 0)
ckfree(s);
error("%.*s: is read only", vp->name_len, s);
}
if (flags & VNOSET)
return;
INTOFF;