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

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

From:
Ilya Zakharevich
Date:
November 17, 1999 15:32
Subject:
Re: [ID 19991116.002] perl5.005_02: my_setenv() and Term::ReadLine::Gnu
Message ID:
19991117183207.A950@monk.mps.ohio-state.edu
On Thu, Nov 18, 1999 at 12:24:05AM +0100, Joerg Schumacher wrote:
> 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

*What* it calls Safefree() on?  How can it be that this is unallocated?
Judging by what you wrote, you are running some old version of Perl,
such as 5.005_03.  In 5.005_50 I can see that the only Safefree() is
done on environ[i].  Due to documentation of putenv() I can see,
environ[i] *should be* malloced.

I think you need to concentrate on these questions.

Ilya



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