diff options
| author | 2022-02-24 03:27:26 +0000 | |
|---|---|---|
| committer | 2022-02-24 03:27:26 +0000 | |
| commit | 589f3e487103f0f0ac61ec5babd142f923fd1a5b (patch) | |
| tree | b8782d9c98e411535ab1a5e658cd4aaaebc900fd | |
| parent | 9e70a83ea0c54d4cb62b720155782edf2f00f1a3 (diff) | |
| parent | d53c27404d916dbb7686add4173acc57861889da (diff) | |
Merge "bit: avoid calling strdup(NULL)"
| -rw-r--r-- | tools/bit/command.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/bit/command.cpp b/tools/bit/command.cpp index f95ea117a96e..6c68e0b0ff6b 100644 --- a/tools/bit/command.cpp +++ b/tools/bit/command.cpp @@ -192,10 +192,11 @@ exec_with_path_search(const char* prog, char const* const* argv, char const* con if (strchr(prog, '/') != NULL) { return execve(prog, (char*const*)argv, (char*const*)envp); } else { - char* pathEnv = strdup(getenv("PATH")); - if (pathEnv == NULL) { + const char* pathEnvRaw = getenv("PATH"); + if (pathEnvRaw == NULL) { return 1; } + char* pathEnv = strdup(pathEnvRaw); char* dir = pathEnv; while (dir) { char* next = strchr(dir, ':'); |