[Scummvm-git-logs] scummvm master -> 51012c33a6de05bd2e5529291674d453e439d715
athrxx
noreply at scummvm.org
Fri Oct 11 23:47:36 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:
51012c33a6 SCI: improve last commit (Japanese text input)
Commit: 51012c33a6de05bd2e5529291674d453e439d715
https://github.com/scummvm/scummvm/commit/51012c33a6de05bd2e5529291674d453e439d715
Author: athrxx (athrxx at scummvm.org)
Date: 2024-10-12T01:47:10+02:00
Commit Message:
SCI: improve last commit (Japanese text input)
(914e017290975614b65d1d44e5d2b31c2b2ab803)
It did fix the problem, but it kind of defeated the purpose of
the strnlen safety check. Now it gets the correct length...
Changed paths:
engines/sci/parser/vocabulary.cpp
engines/sci/parser/vocabulary.h
diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp
index 95367b5dda9..c5cdd8998a4 100644
--- a/engines/sci/parser/vocabulary.cpp
+++ b/engines/sci/parser/vocabulary.cpp
@@ -373,6 +373,7 @@ bool Vocabulary::loadAltInputs() {
if (l == maxSize) {
error("Alt input replacement from %s appears truncated at %d", resource->name().c_str(), it - resource->cbegin());
}
+ t._replacementLength = l;
it += l + 1;
if (it < end && strncmp((const char *)&*it, t._input, t._inputLength) == 0)
@@ -424,11 +425,10 @@ bool Vocabulary::checkAltInput(Common::String &text, uint16 &cursorPos) {
continue;
if (strncmp(i->_input, t+p, i->_inputLength) == 0) {
// replace
- const uint32 maxSize = text.size() - cursorPos;
if (cursorPos > p + i->_inputLength) {
- cursorPos += Common::strnlen(i->_replacement, maxSize) - i->_inputLength;
+ cursorPos += i->_replacementLength - i->_inputLength;
} else if (cursorPos > p) {
- cursorPos = p + Common::strnlen(i->_replacement, text.size());
+ cursorPos = p + i->_replacementLength;
}
for (uint32 j = 0; j < i->_inputLength; ++j)
diff --git a/engines/sci/parser/vocabulary.h b/engines/sci/parser/vocabulary.h
index 2155f4d9751..2a3fb52abf6 100644
--- a/engines/sci/parser/vocabulary.h
+++ b/engines/sci/parser/vocabulary.h
@@ -158,6 +158,7 @@ struct AltInput {
const char *_input;
const char *_replacement;
uint32 _inputLength;
+ uint32 _replacementLength;
bool _prefix;
};
More information about the Scummvm-git-logs
mailing list