Avoid duplicate entries in build_envp()

Francois Gouget fgouget at codeweavers.com
Tue Jan 20 11:33:12 CST 2004


The symptoms were pretty weird: in some cases perl scripts started from 
Winelib applications would segfault on startup. And using an 
intermediate bash script (exec "$0.pl" "$@") would fix the problem.

The reason is that when starting a new process Wine would sometimes 
create duplicate entries in the environment which is what caused perl to 
crash. The source of the duplicates is DRIVE_BuildEnv() which is 
responsible for creating the variables of the form "=X:" (these store 
the current directory for each drive letter, as per Windows behavior). 
However we were already inheriting some of these and build_envp() was 
not removing duplicates.

So now build_envp() simply ignores all inherited variables of the form 
"=X:".

Changelog:

  * wine/dlls/kernel/process.c

    Francois Gouget <fgouget at codeweavers.com>
    Avoid duplicate '=C:' entries in the child process environment.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/kernel/process.c
===================================================================
RCS file: /home/cvs/wine/dlls/kernel/process.c,v
retrieving revision 1.41
diff -u -r1.41 process.c
--- dlls/kernel/process.c	20 Jan 2004 02:11:06 -0000	1.41
+++ dlls/kernel/process.c	20 Jan 2004 10:29:39 -0000
@@ -1069,6 +1069,9 @@
         {
             if (!memcmp( p, "PATH=", 5 ))  /* store PATH as WINEPATH */
                 *envptr++ = alloc_env_string( "WINEPATH=", p + 5 );
+            else if (p[0]=='=' && 'A'<=p[1] && p[1]<='Z' && p[2]==':' &&
+                     p[3]=='=')
+            { /* skipped */ }
             else if (memcmp( p, "HOME=", 5 ) &&
                      memcmp( p, "WINEPATH=", 9 ) &&
                      memcmp( p, "WINEPREFIX=", 11 )) *envptr++ = p;


More information about the wine-patches mailing list