[Lldb-commits] [PATCH] D100795: [lldb] Fix RichManglingContext::FromCxxMethodName() leak
Jordan Rupprecht via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 19 14:36:01 PDT 2021
rupprecht created this revision.
rupprecht requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
`RichManglingContext::FromCxxMethodName` allocates a m_cxx_method_parser, but never deletes it.
This fixes a `-DLLVM_USE_SANITIZER=Leaks` failure.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100795
Files:
lldb/include/lldb/Core/RichManglingContext.h
lldb/source/Core/RichManglingContext.cpp
Index: lldb/source/Core/RichManglingContext.cpp
===================================================================
--- lldb/source/Core/RichManglingContext.cpp
+++ lldb/source/Core/RichManglingContext.cpp
@@ -19,6 +19,15 @@
using namespace lldb_private;
// RichManglingContext
+RichManglingContext::~RichManglingContext() {
+ std::free(m_ipd_buf);
+ if (m_cxx_method_parser.hasValue()) {
+ assert(m_provider == PluginCxxLanguage);
+ delete get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser);
+ m_cxx_method_parser.reset();
+ }
+}
+
void RichManglingContext::ResetProvider(InfoProvider new_provider) {
// If we want to support parsers for other languages some day, we need a
// switch here to delete the correct parser type.
Index: lldb/include/lldb/Core/RichManglingContext.h
===================================================================
--- lldb/include/lldb/Core/RichManglingContext.h
+++ lldb/include/lldb/Core/RichManglingContext.h
@@ -29,7 +29,7 @@
m_ipd_buf[0] = '\0';
}
- ~RichManglingContext() { std::free(m_ipd_buf); }
+ ~RichManglingContext();
/// Use the ItaniumPartialDemangler to obtain rich mangling information from
/// the given mangled name.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100795.338645.patch
Type: text/x-patch
Size: 1214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210419/34dc241e/attachment.bin>
More information about the lldb-commits
mailing list