diff options
author | jilles <jilles@FreeBSD.org> | 2014-03-27 22:57:23 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2014-03-27 22:57:23 +0000 |
commit | 74ddfdb12220a0706416f9c7ff682fcd702fbb5c (patch) | |
tree | 161ab36f609a527c8691696648e876040cd3d0ea | |
parent | ce55d2a4469eaa4ee8a72a8428ecd64d53a14db1 (diff) | |
download | FreeBSD-src-74ddfdb12220a0706416f9c7ff682fcd702fbb5c.zip FreeBSD-src-74ddfdb12220a0706416f9c7ff682fcd702fbb5c.tar.gz |
sh: Fix memory leak with an assignment before a regular builtin.
MFC after: 1 week
-rw-r--r-- | bin/sh/var.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/sh/var.c b/bin/sh/var.c index da13de7..ebeff16 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -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; |