aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2014-03-27 22:57:23 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2014-03-27 22:57:23 +0000
commitd73dba75d6efba3fcb896a04ed28a42940493a29 (patch)
tree161ab36f609a527c8691696648e876040cd3d0ea /bin
parent89d4f883a48d04fadec712f124a80ea13268d989 (diff)
downloadsrc-d73dba75d6efba3fcb896a04ed28a42940493a29.tar.gz
src-d73dba75d6efba3fcb896a04ed28a42940493a29.zip
sh: Fix memory leak with an assignment before a regular builtin.
MFC after: 1 week
Notes
Notes: svn path=/head/; revision=263847
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/var.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/sh/var.c b/bin/sh/var.c
index da13de7f2ce8..ebeff16635fb 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;