diff options
author | 2009-08-13 02:16:40 +0000 | |
---|---|---|
committer | 2009-08-13 02:16:40 +0000 | |
commit | f029e36352c6a0bf991f0a6100d68b28f0b31dc9 (patch) | |
tree | bbac4ef550008fc69382e3a89aa74fb9fbd1356a | |
parent | Fix compilation warnings (bug #280373). (diff) | |
download | eselect-python-f029e36352c6a0bf991f0a6100d68b28f0b31dc9.tar.gz eselect-python-f029e36352c6a0bf991f0a6100d68b28f0b31dc9.tar.bz2 eselect-python-f029e36352c6a0bf991f0a6100d68b28f0b31dc9.zip |
Fix segmentation fault when PATH isn't set (bug #280780).
-rw-r--r-- | python.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -33,7 +33,15 @@ const char* find_path(const char* exe) { return strndup(exe, last_slash - exe); } - char* path = strdup(getenv("PATH")); + const char* PATH = getenv("PATH"); + if (! PATH) + { + /* If PATH is unset, then it defaults to ":/bin:/usr/bin", per + * execvp(3). + */ + PATH = ":/bin:/usr/bin"; + } + char* path = strdup(PATH); char* state = NULL; const char* token = strtok_r(path, ":", &state); while (token) |