aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2021-08-11 16:56:36 +0100
committerMed Ismail Bennani <medismail.bennani@gmail.com>2021-08-11 17:03:20 +0100
commitbe556d5131d56f285e55b0548f3b953d55d055c4 (patch)
tree087d8147597388a797256004e10cbdc5b0ef1afd /lldb/source/Commands/CommandObjectProcess.cpp
parent885be620f90b87deb542258e50985512ecf6d550 (diff)
downloadllvm-be556d5131d56f285e55b0548f3b953d55d055c4.zip
llvm-be556d5131d56f285e55b0548f3b953d55d055c4.tar.gz
llvm-be556d5131d56f285e55b0548f3b953d55d055c4.tar.bz2
[lldb/Commands] Fix heap-use-after-free error in CommandObjectProcess
This patch should fix the use-after-free error that was brought up by the LLDB ASAN Green Dragon bot. This is caused because the `StringRef` object was acquired too early before being use and by the underlying memory was modified which caused it to point to null memory. Fetching back the string reference close to its usage location should fix the issue. Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 7aaba37..1a8ed02 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -170,8 +170,6 @@ protected:
if (!StopProcessIfNecessary(m_exe_ctx.GetProcessPtr(), state, result))
return false;
- llvm::StringRef target_settings_argv0 = target->GetArg0();
-
// Determine whether we will disable ASLR or leave it in the default state
// (i.e. enabled if the platform supports it). First check if the process
// launch options explicitly turn on/off
@@ -216,6 +214,8 @@ protected:
m_options.launch_info.GetEnvironment().insert(target_env.begin(),
target_env.end());
+ llvm::StringRef target_settings_argv0 = target->GetArg0();
+
if (!target_settings_argv0.empty()) {
m_options.launch_info.GetArguments().AppendArgument(
target_settings_argv0);