[Lldb-commits] [lldb] aa728ff - [lldb] Fix stack-use-after-scope issue in ScriptedInterface.h
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 6 16:35:43 PST 2023
Author: Med Ismail Bennani
Date: 2023-03-06T16:35:24-08:00
New Revision: aa728ff754e9de91f20fca1e2847d69a81cccb75
URL: https://github.com/llvm/llvm-project/commit/aa728ff754e9de91f20fca1e2847d69a81cccb75
DIFF: https://github.com/llvm/llvm-project/commit/aa728ff754e9de91f20fca1e2847d69a81cccb75.diff
LOG: [lldb] Fix stack-use-after-scope issue in ScriptedInterface.h
This patch should fix a `stack-use-after-scope` in the helper function
`ScriptedInterface::ErrorWithMessage`.
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Added:
Modified:
lldb/include/lldb/Interpreter/ScriptedInterface.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/Interpreter/ScriptedInterface.h b/lldb/include/lldb/Interpreter/ScriptedInterface.h
index 8785e31f7b932..ab61425932643 100644
--- a/lldb/include/lldb/Interpreter/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/ScriptedInterface.h
@@ -40,12 +40,16 @@ class ScriptedInterface {
LLDBLog log_caterogy = LLDBLog::Process) {
LLDB_LOGF(GetLog(log_caterogy), "%s ERROR = %s", caller_name.data(),
error_msg.data());
- llvm::Twine err = llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
- llvm::Twine(error_msg));
+ std::string full_error_message =
+ llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
+ llvm::Twine(error_msg))
+ .str();
if (const char *detailed_error = error.AsCString())
- err.concat(llvm::Twine(" (") + llvm::Twine(detailed_error) +
- llvm::Twine(")"));
- error.SetErrorString(err.str());
+ full_error_message +=
+ llvm::Twine(llvm::Twine(" (") + llvm::Twine(detailed_error) +
+ llvm::Twine(")"))
+ .str();
+ error.SetErrorString(full_error_message);
return {};
}
More information about the lldb-commits
mailing list