From: Jingyi Hou Date: Thu, 23 May 2013 18:18:23 +0000 (+0800) Subject: search_for_executable() fails to process last part of PATH if PATH does not end with ':' X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=2cabe4e99e16a0d92969414b23a8a065e5e41a72;p=sbcl.git search_for_executable() fails to process last part of PATH if PATH does not end with ':' --- diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 49c007b..cacc9c7 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -287,6 +287,18 @@ search_for_executable(const char *argv0) return search; } } + /* The above for-loop fails to process the last part of PATH if PATH does + * not end with ':'. We may consider appending an extra ':' to the end of + * SEARCH. -- houjingyi 2013-05-24 */ + if (start != NULL && *start != '\0') { + snprintf(buf, PATH_MAX + 1, "%s/%s", start, argv0); + if (access(buf, F_OK) == 0) { + free(search); + search = copied_realpath(buf); + free(buf); + return search; + } + } free(search); free(buf);