diff options
author | jilles <jilles@FreeBSD.org> | 2014-04-15 18:24:24 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2014-04-15 18:24:24 +0000 |
commit | 7ba0eb2fc1e97128bbb94ff8eacde6ef7cd4ac0c (patch) | |
tree | 0c437e9770b365444bd2af5dd220d4b843298cb0 /bin/sh | |
parent | 9b6cbf64ed666f5a16495268e32941a66215e3d0 (diff) | |
download | FreeBSD-src-7ba0eb2fc1e97128bbb94ff8eacde6ef7cd4ac0c.zip FreeBSD-src-7ba0eb2fc1e97128bbb94ff8eacde6ef7cd4ac0c.tar.gz |
MFC r263846: sh: Fix memory leak when trying to set a read only variable.
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/var.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/sh/var.c b/bin/sh/var.c index 6c0685f..da13de7 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -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; |