diff options
author | Matthew Hoops | 2010-06-06 22:44:14 +0000 |
---|---|---|
committer | Matthew Hoops | 2010-06-06 22:44:14 +0000 |
commit | 51a897845532cc1fe587352726051e5f420d5d68 (patch) | |
tree | cdc48dcccb331c852feb51b8adf1fb913ae8f4fa /engines/sci/engine/kernel32.cpp | |
parent | 548015ac10c89da839343b12274123898c113df1 (diff) | |
download | scummvm-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
Diffstat (limited to 'engines/sci/engine/kernel32.cpp')
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 12 |
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]); |