Module: wine Branch: refs/heads/master Commit: 767ad69a456f4ba2e35d297069188a0e5773a62c URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=767ad69a456f4ba2e35d2970...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Feb 16 20:06:20 2006 +0100
libwine: Don't rely on argv[0] in wine_exec_wine_binary if we can get the directory from the library itself. Only try the hardcoded BINDIR if everything else failed.
---
libs/wine/config.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/libs/wine/config.c b/libs/wine/config.c index 7b4c969..e2bdc5a 100644 --- a/libs/wine/config.c +++ b/libs/wine/config.c @@ -154,7 +154,7 @@ static const char *get_runtime_libdir(vo }
/* determine the proper location of the given path based on the current libdir */ -static char *get_path_from_libdir( const char *path, const char *filename ) +static char *get_path_from_libdir( const char *path, const char *fallback, const char *filename ) { char *p, *ret; const char *libdir = get_runtime_libdir(); @@ -184,6 +184,7 @@ static char *get_path_from_libdir( const } else { + if (fallback) path = fallback; ret = xmalloc( strlen(path) + strlen(filename) + 2 ); strcpy( ret, path ); p = ret + strlen(ret); @@ -229,7 +230,7 @@ const char *get_default_dlldir(void) { static const char *dlldir;
- if (!dlldir) dlldir = get_path_from_libdir( DLLDIR, "" ); + if (!dlldir) dlldir = get_path_from_libdir( DLLDIR, NULL, "" ); return dlldir; }
@@ -409,6 +410,7 @@ static void preloader_exec( char **argv, /* exec a wine internal binary (either the wine loader or the wine server) */ void wine_exec_wine_binary( const char *name, char **argv, char **envp, int use_preloader ) { + static const char bindir[] = BINDIR; const char *path, *pos, *ptr;
if (name && strchr( name, '/' )) @@ -419,21 +421,11 @@ void wine_exec_wine_binary( const char * } else if (!name) name = argv0_name;
- /* first, try bin directory */ - argv[0] = get_path_from_libdir( BINDIR, name ); + /* first, bin directory from the current libdir or argv0 */ + argv[0] = get_path_from_libdir( bindir, argv0_path, name ); preloader_exec( argv, envp, use_preloader ); free( argv[0] );
- /* now try the path of argv0 of the current binary */ - if (argv0_path) - { - argv[0] = xmalloc( strlen(argv0_path) + strlen(name) + 1 ); - strcpy( argv[0], argv0_path ); - strcat( argv[0], name ); - preloader_exec( argv, envp, use_preloader ); - free( argv[0] ); - } - /* now search in the Unix path */ if ((path = getenv( "PATH" ))) { @@ -452,4 +444,11 @@ void wine_exec_wine_binary( const char * } free( argv[0] ); } + + /* and finally try BINDIR */ + argv[0] = xmalloc( sizeof(bindir) + 1 + strlen(name) ); + strcpy( argv[0], bindir ); + strcat( argv[0], "/" ); + strcat( argv[0], name ); + preloader_exec( argv, envp, use_preloader ); }