Skip to content

Commit

Permalink
Merge pull request #335 from kbinani/fix-resource-leak
Browse files Browse the repository at this point in the history
Fix resource leak in `Archive#makeBackingConfiguration`
  • Loading branch information
weichsel authored Dec 22, 2024
2 parents fac78df + 3e8c558 commit 8c370b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/ZIPFoundation/Archive+BackingConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extension Archive {
throw POSIXError(errno, path: url.path)
}
guard let (eocdRecord, zip64EOCD) = Archive.scanForEndOfCentralDirectoryRecord(in: archiveFile) else {
fclose(archiveFile)
throw ArchiveError.missingEndOfCentralDirectoryRecord
}
return BackingConfiguration(file: archiveFile,
Expand All @@ -71,6 +72,7 @@ extension Archive {
throw POSIXError(errno, path: url.path)
}
guard let (eocdRecord, zip64EOCD) = Archive.scanForEndOfCentralDirectoryRecord(in: archiveFile) else {
fclose(archiveFile)
throw ArchiveError.missingEndOfCentralDirectoryRecord
}
fseeko(archiveFile, 0, SEEK_SET)
Expand Down

0 comments on commit 8c370b8

Please sign in to comment.