[Scummvm-git-logs] scummvm master -> 3faf0d163ba154b594341e07a2fc81096043a737
sluicebox
noreply at scummvm.org
Mon Sep 18 23:17:10 UTC 2023
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:
3faf0d163b SCI: Fix kMessage crash when message stack is empty
Commit: 3faf0d163ba154b594341e07a2fc81096043a737
https://github.com/scummvm/scummvm/commit/3faf0d163ba154b594341e07a2fc81096043a737
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-09-18T16:16:45-07:00
Commit Message:
SCI: Fix kMessage crash when message stack is empty
Fixes a crash due to an assertion failure that appeared in Google Play
Console. This would occur if a script somehow called kMessage to get
the next message from the stack before calling kMessage to initialize.
We don't know what game caused this, but I have confirmed that this was
not a fatal error in the original interpreter. I then tested this with
a custom script that calls kMessage in the wrong order.
Now our behavior matches the original and we log a warning.
Fixes bug #14613
Changed paths:
engines/sci/engine/message.cpp
engines/sci/engine/message.h
diff --git a/engines/sci/engine/message.cpp b/engines/sci/engine/message.cpp
index 4d9c2de7172..b577f2dd3c0 100644
--- a/engines/sci/engine/message.cpp
+++ b/engines/sci/engine/message.cpp
@@ -184,6 +184,15 @@ public:
#endif
bool MessageState::getRecord(CursorStack &stack, bool recurse, MessageRecord &record) {
+ if (stack.empty()) {
+ // SSCI did not check for an empty stack, it would just use the first element
+ // from its zero-initialized array and return false when message lookup failed.
+ // We know that this occurs from crash analytics. kMessage(K_MESSAGE_NEXT)
+ // somehow gets called before an initializing kMessage call. Bug #14613
+ warning("Message: stack is empty");
+ return false;
+ }
+
// find a workaround for the requested message and use the prescribed module
int module = stack.getModule();
MessageTuple &tuple = stack.top();
@@ -317,7 +326,10 @@ int MessageState::nextMessage(reg_t buf) {
g_sci->_tts->setMessage(record.string);
return record.talker;
} else {
- MessageTuple &t = _cursorStack.top();
+ MessageTuple t;
+ if (!_cursorStack.empty()) {
+ t = _cursorStack.top();
+ }
outputString(buf, Common::String::format("Msg %d: %s not found", _cursorStack.getModule(), t.toString().c_str()));
return 0;
}
diff --git a/engines/sci/engine/message.h b/engines/sci/engine/message.h
index 1f7f4a195af..9a43e27fc00 100644
--- a/engines/sci/engine/message.h
+++ b/engines/sci/engine/message.h
@@ -48,6 +48,8 @@ struct MessageTuple {
class CursorStack : public Common::Stack<MessageTuple> {
public:
+ CursorStack() : Common::Stack<MessageTuple>(), _module(0) {}
+
void init(int module, MessageTuple t) {
clear();
push(t);
More information about the Scummvm-git-logs
mailing list