Subject: Re: try again: unsetenv memory leak fix
To: Masaru OKI <oki@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-userlevel
Date: 06/30/2003 09:36:34
Hi,

Two little nits:

First, you have "char **__alloced_env;" in two files.  One of these
should probably be an extern or, even better, there should be an extern
declaration in a header (src/lib/libc/stdlib/local.h looks best).

> Index: __unsetenv13.c
> ===================================================================
> RCS file: /cvsroot/src/lib/libc/stdlib/__unsetenv13.c,v
> retrieving revision 1.2
> diff -u -r1.2 __unsetenv13.c
> --- __unsetenv13.c	2003/04/13 17:39:13	1.2
> +++ __unsetenv13.c	2003/06/29 19:14:47
> [ ... ]
> -	while (__findenv(name, &offset))	/* if set multiple times */
> -		for (p = &environ[offset];; ++p)
> +	while (__findenv(name, &offset)) {	/* if set multiple times */
> +		if (__alloced_env != 0 && __alloced_env[offset] != 0) {

Second, elsewhere we just test "if (__alloced_env)", but not compare it
with anything.  Also, it's probably more aesthetic to compare pointers
against "NULL" instead of "0".


Also, you've mentioned some test programs - maybe these could be added
under src/regress/lib/libc/setenv?

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD Support and Service:         http://www.wasabisystems.com/