aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kstring.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index db218f5097..b09b34c435 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -308,12 +308,14 @@ reg_t kStrAt(EngineState *s, int argc, reg_t *argv) {
if (argc > 2)
newvalue = argv[2].toSint16();
+ // in kq5 this here gets called with offset 0xFFFF
+ // (in the desert wheng getting the staff)
+ if ((int)offset >= dest_r.maxSize) {
+ warning("kStrAt offset %X exceeds maxSize", offset);
+ return s->r_acc;
+ }
+
if (dest_r.isRaw) {
- // in kq5 this here gets called with offset 0xFFFF
- if ((int)offset > dest_r.maxSize) {
- warning("kStrAt offset %X exceeds maxSize", offset);
- return s->r_acc;
- }
value = dest_r.raw[offset];
if (argc > 2) /* Request to modify this char */
dest_r.raw[offset] = newvalue;