Skip to content

Commit c35d65e

Browse files
authored
Merge pull request #79155 from weissi/jw-bt-leak
fix ELF/DWARF leak
2 parents 8c5b49e + e533b8a commit c35d65e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

stdlib/public/RuntimeModule/Dwarf.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ protocol DwarfSource {
502502

503503
}
504504

505-
struct DwarfReader<S: DwarfSource> {
505+
struct DwarfReader<S: DwarfSource & AnyObject> {
506506

507507
typealias Source = S
508508
typealias Address = UInt64
@@ -513,7 +513,7 @@ struct DwarfReader<S: DwarfSource> {
513513
var end: Address { return base + size }
514514
}
515515

516-
var source: Source
516+
unowned var source: Source
517517

518518
struct AbbrevInfo {
519519
var tag: Dwarf_Tag

stdlib/public/RuntimeModule/Elf.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,8 +1793,9 @@ final class ElfImage<SomeElfTraits: ElfTraits>
17931793
}
17941794
}
17951795

1796-
private lazy var dwarfReader
1797-
= try? DwarfReader(source: self, shouldSwap: header.shouldByteSwap)
1796+
private lazy var dwarfReader = { [unowned self] in
1797+
try? DwarfReader(source: self, shouldSwap: header.shouldByteSwap)
1798+
}()
17981799

17991800
typealias CallSiteInfo = DwarfReader<ElfImage>.CallSiteInfo
18001801

0 commit comments

Comments
 (0)