[9595] in Athena Bugs

home help back first fref pref prev next nref lref last post

rt 7.4G: memory leak in BSD setenv()

daemon@ATHENA.MIT.EDU (Barr3y Jaspan)
Sun Jul 12 12:55:56 1992

To: bugs@Athena.MIT.EDU
Date: Sun, 12 Jul 92 12:55:42 EDT
From: "Barr3y Jaspan" <bjaspan@Athena.MIT.EDU>

System name:		bill-the-cat
Type and version:	RTPC-ROMPC 7.4G (1 update(s) to same version)
Display type:		apa16

What's wrong:

There seems to be a memory leak in the BSD setenv().  Each time you
call setenv() on a variable that is already defined with a new value
that is longer than the current value, it allocates space for the new
entry without freeing the space used by the old entry.

This bug does not occur (1) if the variable to be defined is not
already defined, since in that case there is no previous entry to free
or (2) if the new value is shorter than the old value, since in that
case the new value is simply copied over the old value.

The offending statement starts on line 66 of
/source/bsd-4.3/common/lib/libc/gen/setenv.c.

What should have happened:

setenv() should not leak memory.

Please describe any relevant documentation references:
	setenv(1)

home help back first fref pref prev next nref lref last post