From a75596c94db26e9e86d6fb222ce4de5e939c2195 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Wed, 19 Aug 2020 23:57:06 +0300 Subject: [PATCH] loader: Fix the generic case in get_self_exe(). Previously this just returned the matched directory, not the path to the executable itself. Signed-off-by: Martin Storsjo Signed-off-by: Alexandre Julliard --- loader/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/loader/main.c b/loader/main.c index 0e6b6f66b50..3c06728504c 100644 --- a/loader/main.c +++ b/loader/main.c @@ -216,13 +216,15 @@ static const char *get_self_exe( char *argv0 ) for (p = strtok( path, ":" ); p; p = strtok( NULL, ":" )) { char *name = build_path( p, argv0 ); - int found = !access( name, X_OK ); + if (!access( name, X_OK )) + { + free( path ); + return name; + } free( name ); - if (found) break; } - if (p) p = strdup( p ); free( path ); - return p; + return NULL; } return argv0; #endif