Merge "bit: avoid calling strdup(NULL)" am: 589f3e4871
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1995590 Change-Id: I5524e43b77097f1bf2c7ac34c877a961cf61b5ad
This commit is contained in:
@@ -192,10 +192,11 @@ exec_with_path_search(const char* prog, char const* const* argv, char const* con
|
|||||||
if (strchr(prog, '/') != NULL) {
|
if (strchr(prog, '/') != NULL) {
|
||||||
return execve(prog, (char*const*)argv, (char*const*)envp);
|
return execve(prog, (char*const*)argv, (char*const*)envp);
|
||||||
} else {
|
} else {
|
||||||
char* pathEnv = strdup(getenv("PATH"));
|
const char* pathEnvRaw = getenv("PATH");
|
||||||
if (pathEnv == NULL) {
|
if (pathEnvRaw == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
char* pathEnv = strdup(pathEnvRaw);
|
||||||
char* dir = pathEnv;
|
char* dir = pathEnv;
|
||||||
while (dir) {
|
while (dir) {
|
||||||
char* next = strchr(dir, ':');
|
char* next = strchr(dir, ':');
|
||||||
|
|||||||
Reference in New Issue
Block a user