aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kscripts.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index 18a677c67f..7bc036bbf8 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -73,11 +73,18 @@ reg_t kLock(EngineState *s, int argc, reg_t *argv) {
// Unloads an arbitrary resource of type 'restype' with resource numbber 'resnr'
reg_t kUnLoad(EngineState *s, int argc, reg_t *argv) {
- int restype = argv[0].toUint16();
- reg_t resnr = argv[1];
+ if (argc >= 2) {
+ int restype = argv[0].toUint16();
+ reg_t resnr = argv[1];
- if (restype == kResourceTypeMemory)
- kfree(s->_segMan, resnr);
+ if (restype == kResourceTypeMemory)
+ kfree(s->_segMan, resnr);
+
+ if (argc > 2)
+ warning("kUnload called with more than 2 parameters (%d)", argc);
+ } else {
+ warning("kUnload called with %d arguments - ignoring", argc);
+ }
return s->r_acc;
}