(ImageFormat.FindFormat): ignore streams less than 4 bytes length.

This commit is contained in:
morkt 2015-10-24 15:51:28 +04:00
parent 12d9ea4765
commit 86d9121b94

View File

@ -152,6 +152,8 @@ namespace GameRes
public static System.Tuple<ImageFormat, ImageMetaData> FindFormat (Stream file, string filename = null) public static System.Tuple<ImageFormat, ImageMetaData> FindFormat (Stream file, string filename = null)
{ {
if (file.Length < 4)
return null;
uint signature = FormatCatalog.ReadSignature (file); uint signature = FormatCatalog.ReadSignature (file);
Lazy<string> ext = null; Lazy<string> ext = null;
if (!string.IsNullOrEmpty (filename)) if (!string.IsNullOrEmpty (filename))