jasonmolenda created this revision.
jasonmolenda added reviewers: jingham, davide.
jasonmolenda added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jasonmolenda requested review of this revision.

Looking over the clang static analyzer, came across this old memory leak - 
looks like it's been around for at least four years.  These two methods both 
call a formatters::*SyntheticFrontEndCreator method which new's an object and 
returns a pointer to it; they save save that pointer but never call delete.  
This patch puts it in an auto_ptr so it'll be destroyed when it goes out of 
scope.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D85396

Files:
  lldb/source/DataFormatters/VectorType.cpp
  lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===================================================================
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -175,9 +175,9 @@
 
 bool lldb_private::formatters::BlockPointerSummaryProvider(
     ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
-      BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children) {
+    std::auto_ptr<SyntheticChildrenFrontEnd> synthetic_children;
+    synthetic_children.reset(BlockPointerSyntheticFrontEndCreator(nullptr, 
valobj.GetSP()));
+  if (!synthetic_children.get()) {
     return false;
   }
 
Index: lldb/source/DataFormatters/VectorType.cpp
===================================================================
--- lldb/source/DataFormatters/VectorType.cpp
+++ lldb/source/DataFormatters/VectorType.cpp
@@ -261,9 +261,9 @@
 
 bool lldb_private::formatters::VectorTypeSummaryProvider(
     ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  auto synthetic_children =
-      VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children)
+  std::auto_ptr<SyntheticChildrenFrontEnd> synthetic_children;
+  synthetic_children.reset(VectorTypeSyntheticFrontEndCreator(nullptr, 
valobj.GetSP()));
+  if (!synthetic_children.get())
     return false;
 
   synthetic_children->Update();


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===================================================================
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -175,9 +175,9 @@
 
 bool lldb_private::formatters::BlockPointerSummaryProvider(
     ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
-      BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children) {
+    std::auto_ptr<SyntheticChildrenFrontEnd> synthetic_children;
+    synthetic_children.reset(BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get()) {
     return false;
   }
 
Index: lldb/source/DataFormatters/VectorType.cpp
===================================================================
--- lldb/source/DataFormatters/VectorType.cpp
+++ lldb/source/DataFormatters/VectorType.cpp
@@ -261,9 +261,9 @@
 
 bool lldb_private::formatters::VectorTypeSummaryProvider(
     ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
-  auto synthetic_children =
-      VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
-  if (!synthetic_children)
+  std::auto_ptr<SyntheticChildrenFrontEnd> synthetic_children;
+  synthetic_children.reset(VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP()));
+  if (!synthetic_children.get())
     return false;
 
   synthetic_children->Update();
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to