[Lldb-commits] [lldb] r333353 - Fix memory leak in SubsPrimitiveParmItanium

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Sun May 27 00:31:07 PDT 2018


Author: teemperor
Date: Sun May 27 00:31:06 2018
New Revision: 333353

URL: http://llvm.org/viewvc/llvm-project?rev=333353&view=rev
Log:
Fix memory leak in SubsPrimitiveParmItanium

Summary:
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.

Reviewers: javed.absar

Subscribers: kristof.beyls, chrib, lldb-commits

Differential Revision: https://reviews.llvm.org/D47418

Modified:
    lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp?rev=333353&r1=333352&r2=333353&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Sun May 27 00:31:06 2018
@@ -309,13 +309,15 @@ static ConstString SubsPrimitiveParmItan
 
   // 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);
 }




More information about the lldb-commits mailing list