Previously this just returned the matched directory, not the path to the executable itself.
Signed-off-by: Martin Storsjo martin@martin.st --- Slightly bigger modification, but more straightforward in the end. --- loader/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/loader/main.c b/loader/main.c index 0e6b6f66b5..3c06728504 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