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 <martin@martin.st>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Martin Storsjo 2020-08-19 23:57:06 +03:00 committed by Alexandre Julliard
parent 1721f0ff27
commit a75596c94d
1 changed files with 6 additions and 4 deletions

View File

@ -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