aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectPlatform.cpp
diff options
context:
space:
mode:
authorJordan Rupprecht <rupprecht@google.com>2022-12-08 16:37:43 -0800
committerJordan Rupprecht <rupprecht@google.com>2022-12-08 16:37:43 -0800
commit23f145daa50c3f51a7fb8c8d68c55e5f4a8027c2 (patch)
treea88014e7a61ad686fcacb5813df8cfaac16363a1 /lldb/source/Commands/CommandObjectPlatform.cpp
parent3b14862f0a968dc079530acbce4f2ca4aa7c1492 (diff)
downloadllvm-23f145daa50c3f51a7fb8c8d68c55e5f4a8027c2.zip
llvm-23f145daa50c3f51a7fb8c8d68c55e5f4a8027c2.tar.gz
llvm-23f145daa50c3f51a7fb8c8d68c55e5f4a8027c2.tar.bz2
[NFC] Fix leak in command options configuration.
`m_options.Append(new OptionPermissions())` leaks because the pointer passed in is not owned. Use a class member to ensure lifetime, which is the common pattern used for this API. Found by the LLDB command interpreter fuzzer. The fuzz input is running `ap $` twice.
Diffstat (limited to 'lldb/source/Commands/CommandObjectPlatform.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 98c6a3b..d72dd06 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -456,12 +456,13 @@ public:
Options *GetOptions() override {
if (!m_options.DidFinalize()) {
- m_options.Append(new OptionPermissions());
+ m_options.Append(&m_option_permissions);
m_options.Finalize();
}
return &m_options;
}
+ OptionPermissions m_option_permissions;
OptionGroupOptions m_options;
};
@@ -519,12 +520,13 @@ public:
Options *GetOptions() override {
if (!m_options.DidFinalize()) {
- m_options.Append(new OptionPermissions());
+ m_options.Append(&m_option_permissions);
m_options.Finalize();
}
return &m_options;
}
+ OptionPermissions m_option_permissions;
OptionGroupOptions m_options;
};