Author: kwk Date: Tue Oct 8 08:56:02 2019 New Revision: 374071 URL: http://llvm.org/viewvc/llvm-project?rev=374071&view=rev Log: [lldb] Avoid resource leak
Summary: 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. Reviewers: jankratochvil, teemperor Reviewed By: teemperor Subscribers: teemperor, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68638 Modified: lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp Modified: lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp?rev=374071&r1=374070&r2=374071&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolverScripted.cpp Tue Oct 8 08:56:02 2019 @@ -92,7 +92,7 @@ BreakpointResolverScripted::CreateFromSt 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