From bb0d5e00d03680becb349e9fa98e9eb6c83e4c04 Mon Sep 17 00:00:00 2001
From: Colin Snover
Date: Wed, 27 Jul 2016 08:37:13 -0500
Subject: SCI32: Handle remap data outside the game's remap range

---
 engines/sci/graphics/remap32.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'engines/sci/graphics')

diff --git a/engines/sci/graphics/remap32.h b/engines/sci/graphics/remap32.h
index 5f629d733e..1b9628c7be 100644
--- a/engines/sci/graphics/remap32.h
+++ b/engines/sci/graphics/remap32.h
@@ -325,7 +325,12 @@ public:
 	 */
 	inline bool remapEnabled(uint8 color) const {
 		const uint8 index = _remapEndColor - color;
-		assert(index < _remaps.size());
+		// At least KQ7 DOS uses remap colors that are outside the valid remap
+		// range; in these cases, just treat those pixels as skip pixels (which
+		// is how they would be treated in SSCI)
+		if (index >= _remaps.size()) {
+			return false;
+		}
 		return (_remaps[index]._type != kRemapNone);
 	}
 
-- 
cgit v1.2.3