develooper Front page | perl.perl5.porters | Postings from November 1999

[ID 19991116.002] perl5.005_02: my_setenv() and Term::ReadLine::Gnu

From:
Joerg Schumacher
Date:
November 16, 1999 15:42
Subject:
[ID 19991116.002] perl5.005_02: my_setenv() and Term::ReadLine::Gnu
Message ID:
199911162342.AAA10022@aunt.gaertner.de
Hi!

I've had a problem with perl5.005_02 and Term::ReadLine::Gnu dumping
core on a solaris 5.5.1 box.  A little bit of debugging revealed that 
readline-4.0 calls putenv(3) for LINES and COLUMNS during initialization.  
If these vars weren't present in the environment the call to putenv() 
changes the value of char **environ.  my_setenv() tests this value to
decide wether to copy the environment.  In my case it didn't copy and
thus dumped core on Safefree() as result of an assignment to $ENV{PATH}.

Patch appended.

Kind regards,
Joerg 

-- 
 Gaertner Datensysteme                         38114 Braunschweig 
 Joerg Schumacher                              Hamburger Str. 273a
 Tel: 0531-2335555          		       Fax: 0531-2335556




--- perl5.005_02/util.c.orig	Wed Nov 17 00:21:06 1999
+++ perl5.005_02/util.c	Wed Nov 17 00:21:50 1999
@@ -1413,12 +1413,14 @@
 my_setenv(char *nam, char *val)
 {
     register I32 i=setenv_getix(nam);		/* where does it go? */
+    static int copyenv = 1;
 
-    if (environ == PL_origenviron) {	/* need we copy environment? */
+    if (copyenv) {	/* need we copy environment? */
 	I32 j;
 	I32 max;
 	char **tmpenv;
 
+	copyenv = 0;
 	/*SUPPRESS 530*/
 	for (max = i; environ[max]; max++) ;
 	New(901,tmpenv, max+2, char*);



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About