neilharvey / FileSignatures

A small library for detecting the type of a file based on header signature (also known as magic number).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'

xantari opened this issue · comments

When calling: var format = inspector.DetermineFileFormat(ms);

With a MemoryStream that is empty will cause the following error:

System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'

Looks like it is missing bounds checking...

I've changed this in ff0cf26 so that it will return a null value when the passed stream is empty (which is the same behaviour as an unrecognised file format).

This is fixed in v2.0, which will be available on Nuget shortly.