[Bug 8924] values returned by getenv() are not persistent!

wine-bugs at winehq.org wine-bugs at winehq.org
Wed Nov 14 18:58:39 CST 2007


http://bugs.winehq.org/show_bug.cgi?id=8924


Dan Kegel <dank at kegel.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dank at kegel.com




--- Comment #2 from Dan Kegel <dank at kegel.com>  2007-11-14 18:58:37 ---
The problem in comment #1 sounds invalid, and was probably
a failed attempt to produce a minimal test case.
SuSv3 deprecates the global _environ, and encourages you to use
getenv.
When a program modifies the environment,
it's ok for the variables to move, but any pointers retrieved
beforehand by getenv() must remain valid, i.e. point to an old copy of 
the environment.

The problem in comment #2 sounds more interesting.
I can't reproduce it with a simple program.  Here's what I did:
first, I created the following file

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
        const char *foobie=getenv("foobie");
        if (foobie)
                printf("foobie ok, %s\n", foobie);
        else
                printf("foobie not found\n");
}

as foo.c in my wine-git tree, the compiled it with the line

tools/winegcc/winegcc foo.c -L dlls -L libs/wine

and then tested it like this:

$ wine cmd
Z:> set foobie=bletch
Z:> a.out
foobie ok, bletch

I would suggest closing this bug as invalid and opening
a new one with just the real-world problem you're facing
(i.e. the one from #2).


-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list