From owner-freebsd-bugs Tue Aug 10 15: 0:31 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 166BC154D6 for ; Tue, 10 Aug 1999 15:00:21 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id PAA25697; Tue, 10 Aug 1999 15:00:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Tue, 10 Aug 1999 15:00:02 -0700 (PDT) Message-Id: <199908102200.PAA25697@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Peter Jeremy Subject: Re: bin/5604: setenv(3) function has memory leak, other bugs Reply-To: Peter Jeremy Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/5604; it has been noted by GNATS. From: Peter Jeremy To: adrian@FreeBSD.ORG, archie@whistle.com, freebsd-gnats-submit@FreeBSD.ORG Cc: Subject: Re: bin/5604: setenv(3) function has memory leak, other bugs Date: Wed, 11 Aug 1999 07:48:44 +1000 I suspect that it isn't possible to implement setenv(3) in a manner that doesn't leak memory. The approach used in Solaris and OSF/1 (I'm not sure what POSIX mandates) is not to have a setenv(3) at all. Instead putenv(3) directly manipulates the environment and requires that the string pointed to by its argument remain valid (ie not be an automatic variable). This pushes the memory management issue onto the application. Until someone has a brainstorm and actually solves the bug, how about we document the problem: Index: getenv.3 =================================================================== RCS file: /home/CVSROOT/./src/lib/libc/stdlib/getenv.3,v retrieving revision 1.2 diff -u -r1.2 getenv.3 --- getenv.3 1999/07/12 20:47:45 1.2 +++ getenv.3 1999/08/10 21:46:15 @@ -150,3 +150,13 @@ .Fn putenv function appeared in .Bx 4.3 Reno . +.Sh BUGS +Successive calls to +.Fn setenv +or +.Fn putenv +assigning a differently sized +.Ar value +to the same +.Ar name +will result in a memory leak. Peter -- Peter Jeremy (VK2PJ) peter.jeremy@alcatel.com.au Alcatel Australia Limited 41 Mandible St Phone: +61 2 9690 5019 ALEXANDRIA NSW 2015 Fax: +61 2 9690 5982 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message