fix(desktop_exec): skip resolving absolute paths

Previously it'd try to find the absolute binary path in the path env.
This commit is contained in:
grialion
2026-01-16 21:38:43 +01:00
parent 9cfe00c197
commit 2dfd2e5eaf

View File

@@ -18,6 +18,10 @@
// returns NULL on any error // returns NULL on any error
// otherwise it returns the absolute path of the program that MUST BE FREED // otherwise it returns the absolute path of the program that MUST BE FREED
static char* NULLABLE search_path(const char* NNULLABLE for_binary) { static char* NULLABLE search_path(const char* NNULLABLE for_binary) {
if (strchr(for_binary, '/') != NULL) {
// skip absolute paths
return strdup(for_binary);
}
char* path_env = getenv("PATH"); char* path_env = getenv("PATH");
if (!path_env) return NULL; if (!path_env) return NULL;
char* path = strdup(path_env); char* path = strdup(path_env);
@@ -56,7 +60,10 @@ int execvpe_desktop(char** args, char* NNULLABLE* NNULLABLE envlist) {
free(args[0]); free(args[0]);
args[0] = new_arg; args[0] = new_arg;
return execve(args[0], args, envlist); int status = execve(args[0], args, envlist);
free(new_arg);
return status;
} }
// parse Exec=/bin/prog arg1 arg2\ with\ spaces // parse Exec=/bin/prog arg1 arg2\ with\ spaces