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

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

From:
Joerg Schumacher
Date:
November 17, 1999 15:24
Subject:
Re: [ID 19991116.002] perl5.005_02: my_setenv() and Term::ReadLine::Gnu
Message ID:
199911172324.AAA28033@aunt.gaertner.de
Hi!

> > The test
> > 
> > 	if (environ == PL_origenviron)
> > 
> > in util.c:my_setenv() assumes that the char **environ will only be
> > modified by perl itself.
> 
> How does it assume it?  Do you try to imply that environ may be
> changed before a call to perl_parse()?

No, the scenario is as follows:

   1) perl_parse() saves the pointer to the environment in PL_origenviron
   2) some extension interface (here Term::ReadLine::Gnu) is called
      and does modify the pointer to the environment via putenv(3)
   3) the perlscript tries to assign a new value to an environment
      variable and perl therefore calls my_setenv()
   4) my_setenv() does check if it needs to copy the environment but
      the check returns false since (environ != PL_origenviron)
   5) my_setenv() calls Safefree() and free()s some unallocated memory


Kind Regards,
Joerg 

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



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