[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

llvm-svn: 374071
This commit is contained in:
Konrad Kleine 2019-10-08 15:56:02 +00:00
parent d80c2520d9
commit 6d7fb29914
1 changed files with 1 additions and 1 deletions

View File

@ -92,7 +92,7 @@ BreakpointResolverScripted::CreateFromStructuredData(
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) {