From c8d7066f24643448671a7b26ff16817a33f5bca8 Mon Sep 17 00:00:00 2001 From: morkt Date: Mon, 20 Jul 2015 00:20:30 +0400 Subject: [PATCH] (ElgFormat.Reader): moved output bounds check into loop body. --- ArcFormats/ImageELG.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ArcFormats/ImageELG.cs b/ArcFormats/ImageELG.cs index 88151317..b662ff9a 100644 --- a/ArcFormats/ImageELG.cs +++ b/ArcFormats/ImageELG.cs @@ -155,10 +155,10 @@ namespace GameRes.Formats.Lucifen void UnpackIndexed (byte[] output) { int dst = 0; - while (dst < m_output.Length) + for (;;) { byte flags = m_input.ReadByte(); - if (0xff == flags) + if (0xff == flags || dst >= m_output.Length) break; int count, pos; @@ -228,10 +228,10 @@ namespace GameRes.Formats.Lucifen void UnpackRGBA () { int dst = 0; - while (dst < m_output.Length) + for (;;) { byte flags = m_input.ReadByte(); - if (0xff == flags) + if (0xff == flags || dst >= m_output.Length) break; int count, pos, src; @@ -255,7 +255,7 @@ namespace GameRes.Formats.Lucifen if (0 != (flags & 0x20)) count = ((flags & 0x1f) << 8) + m_input.ReadByte() + 34; else - count = (flags & 0x1f) + 2; + count = (flags & 0x1f) + 2; byte b = m_input.ReadByte(); byte g = m_input.ReadByte(); @@ -354,10 +354,10 @@ namespace GameRes.Formats.Lucifen public void UnpackAlpha () { int dst = 3; - while (dst < m_output.Length) + for (;;) { byte flags = m_input.ReadByte(); - if (0xff == flags) + if (0xff == flags || dst >= m_output.Length) break; int count, pos; @@ -439,10 +439,10 @@ namespace GameRes.Formats.Lucifen void UnpackRGB () { int dst = 0; - while (dst < m_output.Length) + for (;;) { byte flags = m_input.ReadByte(); - if (0xff == flags) + if (0xff == flags || dst >= m_output.Length) break; int count, pos, src; if (0 == (flags & 0xc0))