[Scummvm-git-logs] scummvm master -> faafefc8337d9d4b4bbbdb1b3139d371c5ee6ec4
sev-
sev at scummvm.org
Fri Jan 31 15:56:12 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1f9eac65be GLK: Fix warnings
faafefc833 PRINCE: Fix warnings and undefined behaviour
Commit: 1f9eac65be97f010246999ac56e28f6c8043b401
https://github.com/scummvm/scummvm/commit/1f9eac65be97f010246999ac56e28f6c8043b401
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-31T16:37:12+01:00
Commit Message:
GLK: Fix warnings
Changed paths:
engines/glk/adrift/scprops.cpp
engines/glk/agt/agtread.cpp
engines/glk/windows.cpp
engines/glk/windows.h
diff --git a/engines/glk/adrift/scprops.cpp b/engines/glk/adrift/scprops.cpp
index e5474d8..aab21d5 100644
--- a/engines/glk/adrift/scprops.cpp
+++ b/engines/glk/adrift/scprops.cpp
@@ -937,7 +937,7 @@ void prop_debug_dump(sc_prop_setref_t bundle) {
sc_trace("bundle->dictionary =\n");
for (index_ = 0; index_ < bundle->dictionary_length; index_++) {
sc_trace("%3ld : %p \"%s\"\n", index_,
- bundle->dictionary[index_], bundle->dictionary[index_]);
+ (void *)bundle->dictionary[index_], bundle->dictionary[index_]);
}
sc_trace("bundle->node_pools_length = %ld\n", bundle->node_pools_length);
diff --git a/engines/glk/agt/agtread.cpp b/engines/glk/agt/agtread.cpp
index 7fce329..885e230 100644
--- a/engines/glk/agt/agtread.cpp
+++ b/engines/glk/agt/agtread.cpp
@@ -1076,7 +1076,7 @@ noun inside information; this is used by agtout */
if (aver >= AGT18 && aver <= AGT18MAX) {
bold_mode = 1;
build_fixchar();
- fixchar['\\'] = FORMAT_CODE;
+ fixchar[(int)'\\'] = FORMAT_CODE;
}
if (aver < AGTME10) {
diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp
index c1ed50a..bea4f59 100644
--- a/engines/glk/windows.cpp
+++ b/engines/glk/windows.cpp
@@ -737,7 +737,7 @@ void Window::getSize(uint *width, uint *height) const {
void Window::bringToFront() {
PairWindow *pairWin = dynamic_cast<PairWindow *>(_parent);
-
+
if (pairWin && pairWin->_dir == winmethod_Arbitrary && pairWin->_children.back() != this) {
pairWin->_children.remove(this);
pairWin->_children.push_back(this);
diff --git a/engines/glk/windows.h b/engines/glk/windows.h
index 8d71303..ef9068f 100644
--- a/engines/glk/windows.h
+++ b/engines/glk/windows.h
@@ -59,7 +59,7 @@ public:
/**
* Constructor
*/
- iterator(Windows *windows, Window *start) : _windows(windows), _current(start) {}
+ iterator(Windows *windows, Window *start) : _current(start) { _windows = windows; }
/**
* Dereference
Commit: faafefc8337d9d4b4bbbdb1b3139d371c5ee6ec4
https://github.com/scummvm/scummvm/commit/faafefc8337d9d4b4bbbdb1b3139d371c5ee6ec4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-31T16:53:54+01:00
Commit Message:
PRINCE: Fix warnings and undefined behaviour
Changed paths:
engines/prince/inventory.cpp
engines/prince/script.cpp
engines/prince/script.h
diff --git a/engines/prince/inventory.cpp b/engines/prince/inventory.cpp
index 3183b94..e66815b 100644
--- a/engines/prince/inventory.cpp
+++ b/engines/prince/inventory.cpp
@@ -393,11 +393,9 @@ void PrinceEngine::inventoryLeftMouseButton() {
if (_optionEnabled == 0) {
int invObjExamEvent = _script->scanMobEvents(_invMobList[_selectedMob]._mask, _script->_scriptInfo.invObjExam);
if (invObjExamEvent == -1) {
- // do_standard
- // FIXME: UB?
- // Constness of the pointer returned by c_str() is cast away (which generates a compiler warning)
- // while it potentially gets modified inside printAt()
- printAt(0, 216, (char *)_invMobList[_selectedMob]._examText.c_str(), kNormalWidth / 2, _invExamY);
+ char buf[256];
+ strncpy(buf, _invMobList[_selectedMob]._examText.c_str(), 256);
+ printAt(0, 216, buf, kNormalWidth / 2, _invExamY);
_interpreter->setCurrentString(_invMobList[_selectedMob]._mask + 70000);
setVoice(0, 28, 1);
playSample(28, 0);
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 2581dde..80d6e85 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -441,6 +441,8 @@ Interpreter::Interpreter(PrinceEngine *vm, Script *script, InterpreterFlags *fla
_mode = "fg";
_fgOpcodePC = _script->getStartGameOffset();
_bgOpcodePC = 0;
+
+ memset(_stringBuf, 1, 1024);
}
void Interpreter::debugInterpreter(const char *s, ...) {
@@ -1013,13 +1015,8 @@ void Interpreter::O_XORFLAG() {
void Interpreter::O_GETMOBTEXT() {
int32 mob = readScriptFlagValue();
_currentString = _vm->_locationNr * 100 + mob + 60001;
- // FIXME: UB?
- // This casts away the constness of the pointer returned by c_str() which is
- // stored and potentially modified later (for example in printAt()).
- // Also, the pointer is only valid as long as _vm->_mobList[mob]
- // is around and _vm->_mobList[mob]._examText hasn't been modified by any of its
- // non-const member functions which also might or might not be a problem.
- _string = (byte *)_vm->_mobList[mob]._examText.c_str();
+ strncpy((char *)_stringBuf, _vm->_mobList[mob]._examText.c_str(), 1024);
+ _string = _stringBuf;
debugInterpreter("O_GETMOBTEXT mob %d", mob);
}
@@ -1835,13 +1832,8 @@ void Interpreter::O_DISABLENAK() {
void Interpreter::O_GETMOBNAME() {
int32 modId = readScriptFlagValue();
- // FIXME: UB?
- // This casts away the constness of the pointer returned by c_str() which is
- // stored and potentially modified later (for example in printAt()).
- // Also, the pointer is only valid as long as _vm->_mobList[mobId]
- // is around and _vm->_mobList[mobId]._name hasn't been modified by any of its
- // non-const member functions which also might or might not be a problem.
- _string = (byte *)_vm->_mobList[modId]._name.c_str();
+ strncpy((char *)_stringBuf, _vm->_mobList[modId]._name.c_str(), 1024);
+ _string = _stringBuf;
debugInterpreter("O_GETMOBNAME modId %d", modId);
}
diff --git a/engines/prince/script.h b/engines/prince/script.h
index a62e69c..b8b8735 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -225,6 +225,7 @@ private:
uint32 _waitFlag;
byte *_string;
+ byte _stringBuf[1024];
uint32 _currentString;
const char *_mode;
More information about the Scummvm-git-logs
mailing list