Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enumerating ZipArchive.Entries collection throws NullReferenceException #431

Metalnem opened this issue Dec 27, 2018 · 0 comments


Copy link

The following program throws NullReferenceException (assuming that the args[0] contains the path to the attached archive):

using System.Linq;
using SharpCompress.Archives.Zip;

namespace SharpCompress.Run
  public class Program
    public static void Main(string[] args)
      using (var zip = ZipArchive.Open(args[0]))

The stack trace looks like this:

An unhandled exception of type 'System.NullReferenceException' occurred in SharpCompress.dll: 'Object reference not set to an instance of an object.'
   at SharpCompress.Common.Zip.ZipHeaderFactory.ReadHeader(UInt32 headerBytes, BinaryReader reader, Boolean zip64)
   at SharpCompress.Common.Zip.SeekableZipHeaderFactory.<ReadSeekableHeader>d__3.MoveNext()
   at SharpCompress.Archives.Zip.ZipArchive.<LoadEntries>d__16.MoveNext()
   at SharpCompress.LazyReadOnlyCollection`1.LazyLoader.MoveNext()
   at SharpCompress.Utility.ForEach[T](IEnumerable`1 items, Action`1 action)
   at SharpCompress.LazyReadOnlyCollection`1.EnsureFullyLoaded()
   at SharpCompress.LazyReadOnlyCollection`1.get_Count()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at SharpCompress.Run.Program.Main(String[] args) in

Found via SharpFuzz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

1 participant