[Scummvm-git-logs] scummvm master -> 8626c39b2142d27d9bf9ffd0d88b4d28cfaead1d

sev- sev at scummvm.org
Tue Aug 10 18:52:00 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8626c39b21 IMAGE: Fix SMC decoder


Commit: 8626c39b2142d27d9bf9ffd0d88b4d28cfaead1d
    https://github.com/scummvm/scummvm/commit/8626c39b2142d27d9bf9ffd0d88b4d28cfaead1d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-08-10T20:51:42+02:00

Commit Message:
IMAGE: Fix SMC decoder

It is a regression introduced in 6fb49b65955d34bc4f3cdc37afb9908faf81dd42.
Because of this, we were not reading all the bytes from the source.

Changed paths:
    image/codecs/smc.cpp


diff --git a/image/codecs/smc.cpp b/image/codecs/smc.cpp
index 33a08d6539..e132c45abb 100644
--- a/image/codecs/smc.cpp
+++ b/image/codecs/smc.cpp
@@ -135,10 +135,9 @@ const Graphics::Surface *SMCDecoder::decodeFrame(Common::SeekableReadStream &str
 				prevBlockPtr = prevBlockPtr1;
 				for (byte y = 0; y < 4; y++) {
 					for (byte x = 0; x < 4; x++) {
-						if (blockPtr >= pixelSize)
-							break;
-
-						pixels[blockPtr++] = pixels[prevBlockPtr++];
+						if (blockPtr < pixelSize)
+							pixels[blockPtr] = pixels[prevBlockPtr];
+						blockPtr++, prevBlockPtr++;
 					}
 					blockPtr += rowInc;
 					prevBlockPtr += rowInc;
@@ -185,10 +184,9 @@ const Graphics::Surface *SMCDecoder::decodeFrame(Common::SeekableReadStream &str
 
 				for (byte y = 0; y < 4; y++) {
 					for (byte x = 0; x < 4; x++) {
-						if (blockPtr >= pixelSize)
-							break;
-
-						pixels[blockPtr++] = pixels[prevBlockPtr++];
+						if (blockPtr < pixelSize)
+							pixels[blockPtr] = pixels[prevBlockPtr];
+						blockPtr++, prevBlockPtr++;
 					}
 
 					blockPtr += rowInc;
@@ -208,10 +206,9 @@ const Graphics::Surface *SMCDecoder::decodeFrame(Common::SeekableReadStream &str
 				blockPtr = rowPtr + pixelPtr;
 				for (byte y = 0; y < 4; y++) {
 					for (byte x = 0; x < 4; x++) {
-						if (blockPtr >= pixelSize)
-							break;
-
-						pixels[blockPtr++] = pixel;
+						if (blockPtr < pixelSize)
+							pixels[blockPtr] = pixel;
+						blockPtr++;
 					}
 
 					blockPtr += rowInc;
@@ -258,10 +255,10 @@ const Graphics::Surface *SMCDecoder::decodeFrame(Common::SeekableReadStream &str
 
 						flagMask >>= 1;
 
-						if (blockPtr >= pixelSize)
-							break;
+						if (blockPtr < pixelSize)
+							pixels[blockPtr] = _colorPairs[pixel];
 
-						pixels[blockPtr++] = _colorPairs[pixel];
+						blockPtr++;
 					}
 
 					blockPtr += rowInc;
@@ -307,10 +304,9 @@ const Graphics::Surface *SMCDecoder::decodeFrame(Common::SeekableReadStream &str
 						pixel = colorTableIndex + ((colorFlags >> flagMask) & 0x03);
 						flagMask -= 2;
 
-						if (blockPtr >= pixelSize)
-							break;
-
-						pixels[blockPtr++] = _colorQuads[pixel];
+						if (blockPtr < pixelSize)
+							pixels[blockPtr] = _colorQuads[pixel];
+						blockPtr++;
 					}
 					blockPtr += rowInc;
 				}
@@ -375,10 +371,10 @@ const Graphics::Surface *SMCDecoder::decodeFrame(Common::SeekableReadStream &str
 						pixel = colorTableIndex + ((colorFlags >> flagMask) & 0x07);
 						flagMask -= 3;
 
-						if (blockPtr >= pixelSize)
-							break;
+						if (blockPtr < pixelSize)
+							pixels[blockPtr] = _colorOctets[pixel];
 
-						pixels[blockPtr++] = _colorOctets[pixel];
+						blockPtr++;
 					}
 
 					blockPtr += rowInc;
@@ -395,10 +391,10 @@ const Graphics::Surface *SMCDecoder::decodeFrame(Common::SeekableReadStream &str
 				blockPtr = rowPtr + pixelPtr;
 				for (byte y = 0; y < 4; y++) {
 					for (byte x = 0; x < 4; x++) {
-						if (blockPtr >= pixelSize)
-							break;
-
-						pixels[blockPtr++] = stream.readByte();
+						byte b = stream.readByte();
+						if (blockPtr < pixelSize)
+							pixels[blockPtr] = b;
+						blockPtr++;
 					}
 
 					blockPtr += rowInc;




More information about the Scummvm-git-logs mailing list