Do not overflow when decoded CopyQM image is bigger than expected.

This commit is contained in:
2017-10-17 23:34:16 +01:00
parent a8a1cc4d1c
commit 6423a434a5

View File

@@ -295,9 +295,11 @@ namespace DiscImageChef.ImagePlugins
// In case there is omitted data
long sectors = (header.sectorsPerTrack) * header.heads * header.totalCylinders;
byte[] filling = new byte[(sectors * header.sectorSize) - decodedImage.Length];
if(filling.Length > 0)
long fillingLen = (sectors * header.sectorSize) - decodedImage.Length;
if(fillingLen > 0)
{
byte[] filling = new byte[fillingLen];
ArrayHelpers.ArrayFill(filling, (byte)0xF6);
decodedImage.Write(filling, 0, filling.Length);
}