kwk created this revision.
kwk added a reviewer: jankratochvil.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Before the pointer variable `args_dict` was assigned the result of an
allocation with `new` and then `args_dict` is passed to
`GetValueForKeyAsDictionary` which immediatly and unconditionally
assigns `args_dict` to `nullptr`:

  bool GetValueForKeyAsDictionary(llvm::StringRef key,
                                  Dictionary *&result) const {
    result = nullptr;

This caused a memory leak which was found in my coverity scan instance
under CID 224753: https://scan.coverity.com/projects/kwk-llvm-project.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68638

Files:
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp


Index: lldb/source/Breakpoint/BreakpointResolverScripted.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -92,7 +92,7 @@
   depth = (lldb::SearchDepth) depth_as_int;
   
   StructuredDataImpl *args_data_impl = new StructuredDataImpl();
-  StructuredData::Dictionary *args_dict = new StructuredData::Dictionary();
+  StructuredData::Dictionary *args_dict = nullptr;
   success = options_dict.GetValueForKeyAsDictionary(
     GetKey(OptionNames::ScriptArgs), args_dict);
   if (success) {


Index: lldb/source/Breakpoint/BreakpointResolverScripted.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -92,7 +92,7 @@
   depth = (lldb::SearchDepth) depth_as_int;
   
   StructuredDataImpl *args_data_impl = new StructuredDataImpl();
-  StructuredData::Dictionary *args_dict = new StructuredData::Dictionary();
+  StructuredData::Dictionary *args_dict = nullptr;
   success = options_dict.GetValueForKeyAsDictionary(
     GetKey(OptionNames::ScriptArgs), args_dict);
   if (success) {
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PAT... Konrad Wilhelm Kleine via Phabricator via lldb-commits

Reply via email to