[Scummvm-cvs-logs] scummvm master -> 0ccc9189402de806307ca9836196cf29f31b2ab7

digitall dgturner at iee.org
Thu Nov 14 16:15:54 CET 2013


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:
0ccc918940 GUI: Fix for potential bad cursor palette access in warning case.


Commit: 0ccc9189402de806307ca9836196cf29f31b2ab7
    https://github.com/scummvm/scummvm/commit/0ccc9189402de806307ca9836196cf29f31b2ab7
Author: Joel Teichroeb (joel at teichroeb.net)
Date: 2013-11-14T07:11:16-08:00

Commit Message:
GUI: Fix for potential bad cursor palette access in warning case.

Previously, if the colorsFound exceeded the maximum number of
cursor colors, a bad access to the cursor palette buffer could be
performed before the warning was emitted. This reordering avoids
that.

Changed paths:
    gui/ThemeEngine.cpp



diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 688654d..9fe482d 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1360,17 +1360,17 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
 
 			// If there is no entry yet for this color in the palette: Add one
 			if (!colorToIndex.contains(col)) {
+				if (colorsFound >= MAX_CURS_COLORS) {
+					warning("Cursor contains too many colors (%d, but only %d are allowed)", colorsFound, MAX_CURS_COLORS);
+					return false;
+				}
+
 				const int index = colorsFound++;
 				colorToIndex[col] = index;
 
 				_cursorPal[index * 3 + 0] = r;
 				_cursorPal[index * 3 + 1] = g;
 				_cursorPal[index * 3 + 2] = b;
-
-				if (colorsFound > MAX_CURS_COLORS) {
-					warning("Cursor contains too many colors (%d, but only %d are allowed)", colorsFound, MAX_CURS_COLORS);
-					return false;
-				}
 			}
 
 			// Copy pixel from the 16 bit source surface to the 8bit target surface






More information about the Scummvm-git-logs mailing list