Fixed PNGLoader crash with palette containing less than 256 colors.

This commit is contained in:
Andre Mohren
2017-05-29 17:31:56 +02:00
committed by reaperrr
parent a869dacdc4
commit 96ca3baff8

View File

@@ -82,7 +82,7 @@ namespace OpenRA.FileFormats
case "PLTE": case "PLTE":
{ {
palette = new Color[256]; palette = new Color[256];
for (var i = 0; i < 256; i++) for (var i = 0; i < length / 3; i++)
{ {
var r = cr.ReadByte(); var g = cr.ReadByte(); var b = cr.ReadByte(); var r = cr.ReadByte(); var g = cr.ReadByte(); var b = cr.ReadByte();
palette[i] = Color.FromArgb(r, g, b); palette[i] = Color.FromArgb(r, g, b);