From 05206ed429b296ea07b5312e1b3173c9953e3caa Mon Sep 17 00:00:00 2001 From: "Federico G. Schwindt" Date: Thu, 2 Aug 2007 10:50:26 +0000 Subject: fix memory leaks and one potential null deref found by coverity. from netbsd. millert@ ok --- bin/ksh/var.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bin/ksh/var.c') 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 @@ -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; } -- cgit v1.2.3