[Scummvm-git-logs] scummvm master -> ff3b9b3c75173039c618cbdb895f91db61809c00

alexbevi noreply at scummvm.org
Mon Aug 31 11:01:15 UTC 2026


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

Summary:
ff3b9b3c75 ASYLUM: Index partial palette writes by color


Commit: ff3b9b3c75173039c618cbdb895f91db61809c00
    https://github.com/scummvm/scummvm/commit/ff3b9b3c75173039c618cbdb895f91db61809c00
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2026-08-31T06:59:30-04:00

Commit Message:
ASYLUM: Index partial palette writes by color

Fixes CID 1470668

Assisted-by: Codex:gpt-5.6-sol

Changed paths:
    engines/asylum/system/screen.cpp


diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 8a943e2ef84..71ac4c4bbb7 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -288,27 +288,24 @@ void Screen::setMainPalette(const byte *data) {
 
 void Screen::setupPalette(byte *buffer, int start, int count) {
 	// Check parameters
-	if (start < 0 || start > 256)
+	if (start < 0 || start >= 256)
 		error("[Screen::setupPalette] Invalid start parameter (was: %d, valid: [0 ; 255])", start);
 
-	if ((count + start) > 256)
-		error("[Screen::setupPalette] Parameters go past the palette buffer (start: %d, count: %d with sum > 256)", start, count);
+	if (count < 0 || count > 256 - start)
+		error("[Screen::setupPalette] Invalid count parameter (start: %d, count: %d, valid: [0 ; %d])", start, count, 256 - start);
 
 	// TODO: Update transparent palette if needed
 
 	// Setup our main palette
-	if (count > 0) {
-		byte *palette = (byte *)_mainPalette;
-		palette += start;
+	const int32 end = start + count;
+	for (int32 paletteIndex = start; paletteIndex < end; paletteIndex++) {
+		byte *palette = &_mainPalette[3 * paletteIndex];
 
-		for (int32 i = 0; i < count; i++) {
-			palette[0] = (byte)(buffer[0] * 4);
-			palette[1] = (byte)(buffer[1] * 4);
-			palette[2] = (byte)(buffer[2] * 4);
+		palette[0] = (byte)(buffer[0] * 4);
+		palette[1] = (byte)(buffer[1] * 4);
+		palette[2] = (byte)(buffer[2] * 4);
 
-			buffer  += 3;
-			palette += 3;
-		}
+		buffer += 3;
 	}
 
 	// Change the system palette




More information about the Scummvm-git-logs mailing list