diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2007-08-02 10:50:26 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2007-08-02 10:50:26 +0000 |
commit | 05206ed429b296ea07b5312e1b3173c9953e3caa (patch) | |
tree | 7d8ae72cfa95bdcc6baecf4fdce3a1849ce2631c /bin/ksh/var.c | |
parent | b22eaa46195292e9f9419500b716ad479026bc85 (diff) |
fix memory leaks and one potential null deref found by coverity. from netbsd.
millert@ ok
Diffstat (limited to 'bin/ksh/var.c')
-rw-r--r-- | bin/ksh/var.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/ksh/var.c b/bin/ksh/var.c index b4915f0e677..02e0be434e8 100644 --- a/bin/ksh/var.c +++ b/bin/ksh/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.30 2006/05/21 18:40:39 otto Exp $ */ +/* $OpenBSD: var.c,v 1.31 2007/08/02 10:50:25 fgsch Exp $ */ #include "sh.h" #include <time.h> @@ -346,6 +346,7 @@ intval(struct tbl *vp) int setstr(struct tbl *vq, const char *s, int error_ok) { + const char *fs = NULL; int no_ro_check = error_ok & 0x4; error_ok &= ~0x4; if ((vq->flag & RDONLY) && !no_ro_check) { @@ -367,7 +368,7 @@ setstr(struct tbl *vq, const char *s, int error_ok) vq->flag &= ~(ISSET|ALLOC); vq->type = 0; if (s && (vq->flag & (UCASEV_AL|LCASEV|LJUST|RJUST))) - s = formatstr(vq, s); + fs = s = formatstr(vq, s); if ((vq->flag&EXPORT)) export(vq, s); else { @@ -381,6 +382,8 @@ setstr(struct tbl *vq, const char *s, int error_ok) vq->flag |= ISSET; if ((vq->flag&SPECIAL)) setspec(vq); + if (fs) + afree((char *)fs, ATEMP); return 1; } |