Skip to content

Commit 07b8367

Browse files
authored
Merge pull request #62662 from valeriyvan/IRGen-leak
Fix possible memory leak
2 parents a6e056b + eb750a6 commit 07b8367

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,10 @@ swift::irgen::createIRGenModule(SILModule *SILMod, StringRef OutputFilename,
12051205
IRGenOptions &Opts) {
12061206
IRGenerator *irgen = new IRGenerator(Opts, *SILMod);
12071207
auto targetMachine = irgen->createTargetMachine();
1208-
if (!targetMachine)
1208+
if (!targetMachine) {
1209+
delete irgen;
12091210
return std::make_pair(nullptr, nullptr);
1210-
1211+
}
12111212
// Create the IR emitter.
12121213
IRGenModule *IGM = new IRGenModule(
12131214
*irgen, std::move(targetMachine), nullptr, "", OutputFilename,

0 commit comments

Comments
 (0)