aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2006-02-14 09:08:12 +0000
committerGuy Harris <guy@alum.mit.edu>2006-02-14 09:08:12 +0000
commit94c71f063dcfe2634cf4fd5025a1dba42d066ff6 (patch)
tree0dca4a11a36ce2a7a911f7a71c9d69996748c76f /epan
parent58ed459c3384ab09acce58576b844152f9b50a70 (diff)
Fix the loop that checks $PATH for the binary to actually step from one
element of the path to the next element. svn path=/trunk/; revision=17298
Diffstat (limited to 'epan')
-rw-r--r--epan/filesystem.c65
1 files changed, 31 insertions, 34 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c
index e084c751d6..a983f5fee1 100644
--- a/epan/filesystem.c
+++ b/epan/filesystem.c
@@ -316,44 +316,41 @@ init_progfile_dir(const char *arg0
*/
prog_pathname = NULL; /* haven't found it yet */
path_start = getenv("PATH");
- while (path_start != NULL) {
- /*
- * Is there anything left in the path?
- */
- if (*path_start == '\0')
- break; /* no */
-
- path_end = strchr(path_start, ':');
- if (path_end == NULL)
- path_end = path_start + strlen(path_start);
- path_component_len = path_end - path_start;
- path = g_malloc(path_component_len + 1
- + strlen(arg0) + 1);
- memcpy(path, path_start, path_component_len);
- path[path_component_len] = '\0';
- strcat(path, "/");
- strcat(path, arg0);
- if (access(path, X_OK) == 0) {
- /*
- * Found it!
- */
- prog_pathname = path;
- break;
- }
+ if (path_start != NULL) {
+ while (*path_start != '\0') {
+ path_end = strchr(path_start, ':');
+ if (path_end == NULL)
+ path_end = path_start + strlen(path_start);
+ path_component_len = path_end - path_start;
+ path = g_malloc(path_component_len + 1
+ + strlen(arg0) + 1);
+ memcpy(path, path_start, path_component_len);
+ path[path_component_len] = '\0';
+ strcat(path, "/");
+ strcat(path, arg0);
+ if (access(path, X_OK) == 0) {
+ /*
+ * Found it!
+ */
+ prog_pathname = path;
+ break;
+ }
- /*
- * That's not it. If there are more
- * path components to test, try them.
- */
- if (*path_end == '\0') {
/*
- * There's nothing more to try.
+ * That's not it. If there are more
+ * path components to test, try them.
*/
- break;
+ if (*path_end == '\0') {
+ /*
+ * There's nothing more to try.
+ */
+ break;
+ }
+ if (*path_end == ':')
+ path_end++;
+ path_start = path_end;
+ g_free(path);
}
- if (*path_start == ':')
- path_start++;
- g_free(path);
}
}