[ScanDependencies] Fix a memory leak in dependency graph

Fix a memory leak from https://github.com/swiftlang/swift/pull/75134.
This commit is contained in:
Steven Wu
2024-07-15 12:38:27 -07:00
parent a3bf1fc4c2
commit ed936853dc
4 changed files with 9 additions and 10 deletions

View File

@@ -31,12 +31,16 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DependencyScanningTool, swiftscan_scanner_t)
//=== Private Cleanup Functions -------------------------------------------===//
void swiftscan_macro_dependency_dispose(
swiftscan_macro_dependency_set_t *macro) {
if (!macro)
return;
for (unsigned i = 0; i < macro->count; ++i) {
swiftscan_string_dispose(macro->macro_dependencies[i]->moduleName);
swiftscan_string_dispose(macro->macro_dependencies[i]->libraryPath);
swiftscan_string_dispose(macro->macro_dependencies[i]->executablePath);
delete macro->macro_dependencies[i];
}
delete[] macro->macro_dependencies;
delete macro;
}