[Scummvm-cvs-logs] SF.net SVN: scummvm:[49464] scummvm/trunk/engines/sci/engine/kernel32.cpp

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Mon Jun 7 00:44:15 CEST 2010


Revision: 49464
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49464&view=rev
Author:   mthreepwood
Date:     2010-06-06 22:44:14 +0000 (Sun, 06 Jun 2010)

Log Message:
-----------
Throw a warning in kString(At) if the index is out-of-bounds instead of having it assert out.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel32.cpp

Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-06-06 22:24:33 UTC (rev 49463)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-06-06 22:44:14 UTC (rev 49464)
@@ -524,8 +524,16 @@
 		}
 	case 1: // Size
 		return make_reg(0, s->_segMan->getString(argv[1]).size());
-	case 2:  // At (return value at an index)
-		return make_reg(0, s->_segMan->getString(argv[1])[argv[2].toUint16()]);
+	case 2: { // At (return value at an index)
+		Common::String string = s->_segMan->getString(argv[1]);
+
+		if (argv[2].toUint16() >= string.size()) {
+			warning("kString(At): Out of bounds: %d/%d\n", argv[2].toUint16(), string.size());
+			return NULL_REG;
+		}
+
+		return make_reg(0, string[argv[2].toUint16()]);
+	}
 	case 3: { // Atput (put value at an index)
 		SciString *string = s->_segMan->lookupString(argv[1]);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list