Skip to content

Commit 384d69f

Browse files
authored
[lldb] Cleanup dyld_process_t after constructing SharedCacheInfo (llvm#106157)
Without calling `dyld_process_dispose`, LLDB will leak the memory associated with the `dyld_process_t`. rdar://134738265
1 parent 2dbc6d4 commit 384d69f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,12 +650,15 @@ static bool ResolveAndVerifyCandidateSupportDir(FileSpec &path) {
650650
if (!dyld_process)
651651
return false;
652652

653+
auto cleanup_process_on_exit =
654+
llvm::make_scope_exit([&]() { dyld_process_dispose(dyld_process); });
655+
653656
dyld_process_snapshot_t snapshot =
654657
dyld_process_snapshot_create_for_process(dyld_process, nullptr);
655658
if (!snapshot)
656659
return false;
657660

658-
auto on_exit =
661+
auto cleanup_snapshot_on_exit =
659662
llvm::make_scope_exit([&]() { dyld_process_snapshot_dispose(snapshot); });
660663

661664
dyld_shared_cache_t shared_cache =

0 commit comments

Comments
 (0)