diff --git a/SharpCompress/Archive/Zip/ZipArchive.cs b/SharpCompress/Archive/Zip/ZipArchive.cs index 9b30a37f..61a5e3f8 100644 --- a/SharpCompress/Archive/Zip/ZipArchive.cs +++ b/SharpCompress/Archive/Zip/ZipArchive.cs @@ -116,7 +116,7 @@ namespace SharpCompress.Archive.Zip try { ZipHeader header = - headerFactory.ReadStreamHeader(stream).FirstOrDefault(x => x != null && x.ZipHeaderType != ZipHeaderType.Split); + headerFactory.ReadStreamHeader(stream).FirstOrDefault(x => x.ZipHeaderType != ZipHeaderType.Split); if (header == null) { return false; diff --git a/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs b/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs index c9f1e182..6bcffa1d 100644 --- a/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs +++ b/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs @@ -45,17 +45,18 @@ namespace SharpCompress.Common.Zip lastEntryHeader = null; uint headerBytes = reader.ReadUInt32(); header = ReadHeader(headerBytes, reader); - if (header != null) { - // entry could be zero bytes so we need to know that. - if(header.ZipHeaderType == ZipHeaderType.LocalEntry) { - bool isRecording = rewindableStream.IsRecording; - if (!isRecording) { - rewindableStream.StartRecording(); - } - uint nextHeaderBytes = reader.ReadUInt32(); - header.HasData = !IsHeader(nextHeaderBytes); - rewindableStream.Rewind(!isRecording); + + //entry could be zero bytes so we need to know that. + if (header.ZipHeaderType == ZipHeaderType.LocalEntry) + { + bool isRecording = rewindableStream.IsRecording; + if (!isRecording) + { + rewindableStream.StartRecording(); } + uint nextHeaderBytes = reader.ReadUInt32(); + header.HasData = !IsHeader(nextHeaderBytes); + rewindableStream.Rewind(!isRecording); } yield return header; } diff --git a/SharpCompress/Common/Zip/ZipHeaderFactory.cs b/SharpCompress/Common/Zip/ZipHeaderFactory.cs index f6281738..842d77b8 100644 --- a/SharpCompress/Common/Zip/ZipHeaderFactory.cs +++ b/SharpCompress/Common/Zip/ZipHeaderFactory.cs @@ -87,7 +87,7 @@ namespace SharpCompress.Common.Zip return entry; } default: - return null; + throw new NotSupportedException("Unknown header: " + headerBytes); } }