[Lldb-commits] [PATCH] D47418: Fix memory leak in SubsPrimitiveParmItanium
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sun May 27 00:33:04 PDT 2018
teemperor created this revision.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.
FastDemangle gives us a C-string that we own (which is allocated in SymbolDemangler::GetDemangledCopy).
As we are not deleting the string, we leak memory whenever we call SubsPrimitiveParmItanium.
https://reviews.llvm.org/D47418
Files:
source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===================================================================
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -309,13 +309,15 @@
// FastDemangle will call our hook for each instance of a primitive type,
// allowing us to perform substitution
- const char *const demangled =
+ char *const demangled =
FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook);
if (log)
log->Printf("substituted mangling for %s:{%s} %s:{%s}\n",
mangled.str().c_str(), demangled, output_buf.c_str(),
FastDemangle(output_buf.c_str()));
+ // FastDemangle malloc'd this string.
+ free(demangled);
return output_buf == mangled ? ConstString() : ConstString(output_buf);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47418.148742.patch
Type: text/x-patch
Size: 872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180527/dde59d5a/attachment.bin>
More information about the lldb-commits
mailing list