From 3ec76350ec48f41850c9e65815427f5e334e0f66 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Fri, 30 Oct 2009 14:22:22 +0000 Subject: SCI: kStrAt offset checking fixed svn-id: r45537 --- engines/sci/engine/kstring.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'engines') 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; -- cgit v1.2.3