On Thu, Jul 04, 2002 at 01:24:11PM +0200, Stefan Farfeleder wrote: > 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. >
Sorry, here's the real 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:37:30 -0000 @@ -28,6 +28,8 @@ #include <string.h> #include <unistd.h> +char **nargv; + #ifdef SHELL #define main testcmd #include "bltin/bltin.h" @@ -51,6 +53,7 @@ #else va_start(ap, msg); #endif + free(nargv); verrx(2, msg, ap); /*NOTREACHED*/ va_end(ap); @@ -199,7 +202,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 +242,8 @@ syntax(*t_wp, "unexpected operator"); (void)setregid(gid, egid); (void)setreuid(uid, euid); + + free(nargv); return res; }