From 3e8c5586efd0c5105156a9b951d38067c559084c Mon Sep 17 00:00:00 2001 From: kbinani Date: Wed, 4 Sep 2024 04:26:15 +0900 Subject: [PATCH] Close FILE before throwing exception --- Sources/ZIPFoundation/Archive+BackingConfiguration.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/ZIPFoundation/Archive+BackingConfiguration.swift b/Sources/ZIPFoundation/Archive+BackingConfiguration.swift index d39b4720..47428925 100644 --- a/Sources/ZIPFoundation/Archive+BackingConfiguration.swift +++ b/Sources/ZIPFoundation/Archive+BackingConfiguration.swift @@ -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, @@ -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)