From 4e4642d0ed791b227f31bcfcfe35ebc0a7cfc7d2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Jan 2023 16:15:32 +0100 Subject: [PATCH] - fixed buffer size checks for raw textures. --- src/common/textures/formats/rawpagetexture.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/textures/formats/rawpagetexture.cpp b/src/common/textures/formats/rawpagetexture.cpp index 1ee29e13d15..8f1a357b26f 100644 --- a/src/common/textures/formats/rawpagetexture.cpp +++ b/src/common/textures/formats/rawpagetexture.cpp @@ -94,7 +94,7 @@ bool CheckIfRaw(FileReader & data, int desiredsize) { gapAtStart = false; } - else if (ofs >= 64000-1) // Need one byte for an empty column + else if (ofs >= desiredsize-1) // Need one byte for an empty column { return true; } @@ -102,7 +102,7 @@ bool CheckIfRaw(FileReader & data, int desiredsize) { // Ensure this column does not extend beyond the end of the patch const uint8_t *foo2 = (const uint8_t *)foo; - while (ofs < 64000) + while (ofs < desiredsize) { if (foo2[ofs] == 255) { @@ -110,7 +110,7 @@ bool CheckIfRaw(FileReader & data, int desiredsize) } ofs += foo2[ofs+1] + 4; } - if (ofs >= 64000) + if (ofs >= desiredsize) { return true; }