aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2010-06-06 22:44:14 +0000
committerMatthew Hoops2010-06-06 22:44:14 +0000
commit51a897845532cc1fe587352726051e5f420d5d68 (patch)
treecdc48dcccb331c852feb51b8adf1fb913ae8f4fa
parent548015ac10c89da839343b12274123898c113df1 (diff)
downloadscummvm-rg350-51a897845532cc1fe587352726051e5f420d5d68.tar.gz
scummvm-rg350-51a897845532cc1fe587352726051e5f420d5d68.tar.bz2
scummvm-rg350-51a897845532cc1fe587352726051e5f420d5d68.zip
Throw a warning in kString(At) if the index is out-of-bounds instead of having it assert out.
svn-id: r49464
-rw-r--r--engines/sci/engine/kernel32.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp
index b132543206..e093fa6fdf 100644
--- a/engines/sci/engine/kernel32.cpp
+++ b/engines/sci/engine/kernel32.cpp
@@ -524,8 +524,16 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
}
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]);