From 7e4425cb1382576025618769dc555c81cf918c28 Mon Sep 17 00:00:00 2001 From: morkt Date: Wed, 6 Jan 2016 19:33:42 +0400 Subject: [PATCH] (GrFormat): handle zero image size field. --- ArcFormats/Eagls/ImageGR.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ArcFormats/Eagls/ImageGR.cs b/ArcFormats/Eagls/ImageGR.cs index da2226c1..9498a6aa 100644 --- a/ArcFormats/Eagls/ImageGR.cs +++ b/ArcFormats/Eagls/ImageGR.cs @@ -57,6 +57,8 @@ namespace GameRes.Formats.Eagls int height = LittleEndian.ToInt32 (bmp, 0x16); int bpp = LittleEndian.ToInt16 (bmp, 0x1c); int image_size = LittleEndian.ToInt32 (bmp, 0x22); + if (0 == image_size) + image_size = width * height * (bpp / 8); return new GrMetaData { Width = (uint)width, @@ -69,10 +71,7 @@ namespace GameRes.Formats.Eagls public override ImageData Read (Stream stream, ImageMetaData info) { - var meta = info as GrMetaData; - if (null == meta) - throw new ArgumentException ("GrFormat.Read should be supplied with GrMetaData", "info"); - + var meta = (GrMetaData)info; using (var reader = new LzssReader (stream, (int)stream.Length, meta.UnpackedSize+2)) { reader.Unpack();