sh: Fix memory leak with an assignment before a regular builtin.

MFC after:	1 week
This commit is contained in:
Jilles Tjoelker 2014-03-27 22:57:23 +00:00
parent 89d4f883a4
commit d73dba75d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=263847

View File

@ -330,8 +330,11 @@ setvareq(char *s, int flags)
ckfree(s);
error("%.*s: is read only", vp->name_len, s);
}
if (flags & VNOSET)
if (flags & VNOSET) {
if ((flags & (VTEXTFIXED|VSTACK)) == 0)
ckfree(s);
return;
}
INTOFF;
if (vp->func && (flags & VNOFUNC) == 0)
@ -364,8 +367,11 @@ setvareq(char *s, int flags)
return;
}
/* not found */
if (flags & VNOSET)
if (flags & VNOSET) {
if ((flags & (VTEXTFIXED|VSTACK)) == 0)
ckfree(s);
return;
}
INTOFF;
vp = ckmalloc(sizeof (*vp));
vp->flags = flags;