aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorMichael Buch <michaelbuch12@gmail.com>2024-08-20 18:40:54 +0100
committerGitHub <noreply@github.com>2024-08-20 18:40:54 +0100
commit770cd24140038646539602406fff54497793dae8 (patch)
treee7aa15a77ece174b54fc80a4236097542a20c051 /lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
parent7aa22f013e24d20291aad745368ff907baa9dfa4 (diff)
downloadllvm-770cd24140038646539602406fff54497793dae8.zip
llvm-770cd24140038646539602406fff54497793dae8.tar.gz
llvm-770cd24140038646539602406fff54497793dae8.tar.bz2
[lldb][ClangExpressionParser] Don't leak memory when multiplexing ExternalASTSources (#104799)
When we use `SemaSourceWithPriorities` as the `ASTContext`s ExternalASTSource, we allocate a `ClangASTSourceProxy` (via `CreateProxy`) and two `ExternalASTSourceWrapper`. Then we push these sources into a vector in `SemaSourceWithPriorities`. The allocated `SemaSourceWithPriorities` itself will get properly deallocated because the `ASTContext` wraps it in an `IntrusiveRefCntPtr`. But the three sources we allocated earlier will never get released. This patch fixes this by mimicking what `MultiplexExternalSemaSource` does (which is what `SemaSourceWithPriorities` is based on anyway). I.e., when `SemaSourceWithPriorities` gets constructed, it increments the use count of its sources. And on destruction it decrements them. Similarly, to make sure we dealloacted the `ClangASTProxy` properly, the `ExternalASTSourceWrapper` now assumes shared ownership of the underlying source.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp')
0 files changed, 0 insertions, 0 deletions