Skip to content

Commit eb2c0a7

Browse files
authored
Merge pull request #62728 from valeriyvan/ScanDependencies-leak
Fix memory leak
2 parents c3fd8a3 + ba1e24d commit eb2c0a7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,10 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
10571057
subInstanceMap = new CompilerArgInstanceCacheMap;
10581058
localSubInstanceMap = true;
10591059
}
1060+
SWIFT_DEFER {
1061+
if (localSubInstanceMap)
1062+
delete subInstanceMap;
1063+
};
10601064

10611065
auto &diags = invocationInstance.getDiags();
10621066
ForwardingDiagnosticConsumer FDC(invocationInstance.getDiags());
@@ -1117,8 +1121,6 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
11171121
scanningAction(entry, *pInstance, *pCache);
11181122
}
11191123

1120-
if (localSubInstanceMap)
1121-
delete subInstanceMap;
11221124
return false;
11231125
}
11241126

0 commit comments

Comments
 (0)