From owner-freebsd-stable Thu Jul 4 4:21:30 2002 Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B354D37B401; Thu, 4 Jul 2002 04:21:25 -0700 (PDT) Received: from fafoe.dyndns.org (chello212186121237.14.vie.surfer.at [212.186.121.237]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1709643E09; Thu, 4 Jul 2002 04:21:25 -0700 (PDT) (envelope-from stefan@fafoe.dyndns.org) Received: by frog.fafoe (Postfix, from userid 1001) id 3FFDA245; Thu, 4 Jul 2002 13:24:11 +0200 (CEST) Date: Thu, 4 Jul 2002 13:24:11 +0200 From: Stefan Farfeleder To: Eugene Grosbein Cc: FreeBSD-gnats-submit@FreeBSD.ORG, stable@FreeBSD.ORG Subject: Re: /bin/sh with builtin 'test' has memory leaks Message-ID: <20020704112411.GA254@frog.fafoe> References: <200207041016.g64AGhEF017182@grosbein.pp.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="bg08WKrSYDhXBjb5" Content-Disposition: inline In-Reply-To: <200207041016.g64AGhEF017182@grosbein.pp.ru> User-Agent: Mutt/1.5.1i Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 04, 2002 at 06:16:43PM +0800, Eugene Grosbein wrote: > > >Description: > There seem to be memory leak in 'test' command that was not > a problem when it was external command but it became a problem > when 'test' was made builtin. Please try this patch. It isn't particularly elegant, but it cures the leak. Stefan Farfeleder --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="test.patch" Index: src/bin/test/test.c =================================================================== RCS file: /home/ncvs/src/bin/test/test.c,v retrieving revision 1.29.2.5 diff -u -r1.29.2.5 test.c --- src/bin/test/test.c 29 Apr 2002 13:06:02 -0000 1.29.2.5 +++ src/bin/test/test.c 4 Jul 2002 11:19:18 -0000 @@ -46,6 +46,7 @@ #ifndef __STDC__ const char *msg; + free(nargs); va_start(ap); msg = va_arg(ap, const char *); #else @@ -172,6 +173,7 @@ }; struct t_op const *t_wp_op; +char **nargv; char **t_wp; static int aexpr __P((enum token)); @@ -199,7 +201,6 @@ uid_t euid, uid; int i, res; char *p; - char **nargv; /* * XXX copy the whole contents of argv to a newly allocated @@ -240,6 +241,8 @@ syntax(*t_wp, "unexpected operator"); (void)setregid(gid, egid); (void)setreuid(uid, euid); + + free(nargv); return res; } --bg08WKrSYDhXBjb5-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message