diff options
author | jilles <jilles@FreeBSD.org> | 2014-04-15 18:29:05 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2014-04-15 18:29:05 +0000 |
commit | 07966b660eb5b2554e333f6698d0b75c231265f7 (patch) | |
tree | 571a188767be263eb6c4f93c9ce4182c8a570bcf /bin | |
parent | 7ba0eb2fc1e97128bbb94ff8eacde6ef7cd4ac0c (diff) | |
download | FreeBSD-src-07966b660eb5b2554e333f6698d0b75c231265f7.zip FreeBSD-src-07966b660eb5b2554e333f6698d0b75c231265f7.tar.gz |
MFC r263847: sh: Fix memory leak with an assignment before a regular builtin
Diffstat (limited to 'bin')
-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; |