Subject: Re: bin/7873: strange message from top(1)
To: None <current-users@netbsd.org>
From: Matthias Scheler <tron@lyssa.owl.de>
List: current-users
Date: 06/28/1999 22:29:56
In article <199906281315.XAA17003@balrog.supp.cpr.itg.telecom.com.au>,
	Simon Burge <simonb@netbsd.org> writes:
> --- display.c	1999/04/12 06:02:25	1.3
> +++ display.c	1999/06/28 13:14:30
> @@ -95,6 +95,7 @@ int display_resize()
>      if (screenbuf != NULL)
>      {
>  	free(screenbuf);
> +	screenbuf = NULL;
>      }

This one is not necessary because it will never exit the function without
assigning the return value of a malloc(3) call to "screenbuf".

> diff -p -u -r1.4 m_netbsd13.c
> --- m_netbsd13.c	1999/04/12 06:02:27	1.4
> +++ m_netbsd13.c	1999/06/28 13:14:31
> @@ -405,13 +405,17 @@ get_system_info(si)
>  	memory_stats[5] = dbtob(totalsize) / 1024 - memory_stats[4];
>  	/*  Free here, before we malloc again in the next
>  	 *  iteration of this loop.  */
> -	if (seporig)
> +	if (seporig) {
>  		free(seporig);
> +		seporig = NULL;
> +	}

That is indeed the real bug. I already committed the patch after
I tracked it down, too. I should have read "current-users" first.

>      } while (0);
>      /*  Catch the case where we malloc'd, but then exited the
>       *  loop due to nswap != rnswap.  */
> -    if (seporig)
> +    if (seporig) {
>  	    free(seporig);
> +	    seporig = NULL;
> +    }

This one is unnecessary, too. It might even cause a compile warning for
an unnecessary assignment because "seporig" isn't used afterwards.

	Regards

-- 
Matthias Scheler                                http://home.owl.de/~tron/