diff options
author | Greg Clayton <gclayton@apple.com> | 2015-01-06 23:33:34 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2015-01-06 23:33:34 +0000 |
commit | 4067d9b2cc0b3e3da0c5030c804abe2a589ed0cb (patch) | |
tree | 930f3efe9047bcaf873dc500420aafeb9ac5af70 | |
parent | 0b589f1bd9db892a7815fdb5729be8424165e2b8 (diff) |
Fix needed for the new terminal test I previously checked in. It was crashing due to a NULL dereference.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@225316 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | source/Host/macosx/Host.mm | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/source/Host/macosx/Host.mm b/source/Host/macosx/Host.mm index 338e8fb68..269d6f9e9 100644 --- a/source/Host/macosx/Host.mm +++ b/source/Host/macosx/Host.mm @@ -470,24 +470,29 @@ LaunchInNewTerminalWithAppleScript (const char *exe_path, ProcessLaunchInfo &lau // need to be sent to darwin-debug. If we send all environment entries, we might blow the // max command line length, so we only send user modified entries. const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector (); + StringList host_env; const size_t host_env_count = Host::GetEnvironment (host_env); - const char *env_entry; - for (size_t env_idx = 0; (env_entry = envp[env_idx]) != NULL; ++env_idx) + + if (envp && envp[0]) { - bool add_entry = true; - for (size_t i=0; i<host_env_count; ++i) + const char *env_entry; + for (size_t env_idx = 0; (env_entry = envp[env_idx]) != NULL; ++env_idx) { - const char *host_env_entry = host_env.GetStringAtIndex(i); - if (strcmp(env_entry, host_env_entry) == 0) + bool add_entry = true; + for (size_t i=0; i<host_env_count; ++i) { - add_entry = false; - break; + const char *host_env_entry = host_env.GetStringAtIndex(i); + if (strcmp(env_entry, host_env_entry) == 0) + { + add_entry = false; + break; + } + } + if (add_entry) + { + command.Printf(" --env='%s'", env_entry); } - } - if (add_entry) - { - command.Printf(" --env='%s'", env_entry); } } |