[Scummvm-git-logs] scummvm master -> af68eb01737952fadc0c05374501f67e9ab46cb6

bluegr noreply at scummvm.org
Wed Oct 2 12:59:03 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
af68eb0173 GLK: ADVSYS: Fix "crash" when matching with empty nouns array


Commit: af68eb01737952fadc0c05374501f67e9ab46cb6
    https://github.com/scummvm/scummvm/commit/af68eb01737952fadc0c05374501f67e9ab46cb6
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2024-10-02T15:59:00+03:00

Commit Message:
GLK: ADVSYS: Fix "crash" when matching with empty nouns array

This fixes the case for "Starship Columbus" IF game

This game seems to call VM::opMATCH() multiple times per line, and very often would cause an assertion fault for out of bounds access to an array (_nouns). Inputs like "open", "inventory","help" would trigger the assertion fault. Debugging shows that in those cases, the idx var in opMATCH would be "-1" and also the _nouns array would be empty. I've added a check for either in an if clause that essentially fails the match and prevents the out of bounds array access attempt.

The issue was first reported on the forums here: https://forums.scummvm.org/viewtopic.php?p=99929&sid=1d010aa5065115367a5dc3a2c4236434#p99929

Changed paths:
    engines/glk/advsys/vm.cpp


diff --git a/engines/glk/advsys/vm.cpp b/engines/glk/advsys/vm.cpp
index a92f569cdb1..d5df628fff4 100644
--- a/engines/glk/advsys/vm.cpp
+++ b/engines/glk/advsys/vm.cpp
@@ -353,7 +353,11 @@ void VM::opCLASS() {
 
 void VM::opMATCH() {
 	int idx = _stack.pop() - 1;
-	_stack.top() = match(_stack.top(), _nouns[idx]._noun, _nouns[idx]._adjective) ? TRUE : NIL;
+	if (idx < 0 || _nouns.size() == 0) {
+		_stack.top() = NIL;
+	} else {
+		_stack.top() = match(_stack.top(), _nouns[idx]._noun, _nouns[idx]._adjective) ? TRUE : NIL;
+	}
 }
 
 void VM::opPNOUN() {




More information about the Scummvm-git-logs mailing list