Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Aug 1999 15:00:02 -0700 (PDT)
From:      Peter Jeremy <jeremyp@gsmx07.alcatel.com.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/5604: setenv(3) function has memory leak, other bugs
Message-ID:  <199908102200.PAA25697@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/5604; it has been noted by GNATS.

From: Peter Jeremy <jeremyp@gsmx07.alcatel.com.au>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908102200.PAA25697>