[Scummvm-git-logs] scummvm master -> 2a9439182a1a06c9400689be395af14c4f6e42a3
sluicebox
noreply at scummvm.org
Tue Sep 26 18:32:35 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:
2a9439182a SCI32: Fix QFG4 crash on empty import dialog
Commit: 2a9439182a1a06c9400689be395af14c4f6e42a3
https://github.com/scummvm/scummvm/commit/2a9439182a1a06c9400689be395af14c4f6e42a3
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-09-26T11:31:54-07:00
Commit Message:
SCI32: Fix QFG4 crash on empty import dialog
QFG4 attempts to copy from a null array/string, and this had no effect
in the original interpreter. Now we behave the same.
Update kFileIOOpen to handle the script's subsequent attempt to open a
nameless file.
Fixes bug #14646
Changed paths:
engines/sci/engine/kernel_tables.h
engines/sci/engine/kfile.cpp
engines/sci/engine/klists.cpp
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 0119ea4a496..1caf20e81b2 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -527,7 +527,7 @@ static const SciKernelMapSubEntry kArray_subops[] = {
{ SIG_SCI32, 3, MAP_CALL(ArraySetElements), "ri(.*)", kArraySetElements_workarounds },
{ SIG_SCI32, 4, MAP_CALL(ArrayFree), "[r0]", NULL },
{ SIG_SCI32, 5, MAP_CALL(ArrayFill), "riii", kArrayFill_workarounds },
- { SIG_SCI32, 6, MAP_CALL(ArrayCopy), "ririi", NULL },
+ { SIG_SCI32, 6, MAP_CALL(ArrayCopy), "ri[r0]ii", NULL },
// there is no subop 7
{ SIG_SCI32, 8, MAP_CALL(ArrayDuplicate), "r", NULL },
{ SIG_SCI32, 9, MAP_CALL(ArrayGetData), "[or0]", NULL },
@@ -546,7 +546,7 @@ static const SciKernelMapSubEntry kString_subops[] = {
{ SIG_THRU_SCI21MID, 3, MAP_CALL(ArraySetElements), "ri(i*)", kArraySetElements_workarounds },
{ SIG_THRU_SCI21MID, 4, MAP_CALL(StringFree), "[r0]", NULL },
{ SIG_THRU_SCI21MID, 5, MAP_CALL(ArrayFill), "riii", kArrayFill_workarounds },
- { SIG_THRU_SCI21MID, 6, MAP_CALL(ArrayCopy), "ririi", NULL },
+ { SIG_THRU_SCI21MID, 6, MAP_CALL(ArrayCopy), "ri[r0]ii", NULL },
{ SIG_SCI32, 7, MAP_CALL(StringCompare), "[r0][r0](i)", NULL },
{ SIG_THRU_SCI21MID, 8, MAP_CALL(ArrayDuplicate), "r", NULL },
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 8436b18a67c..6b7d66ebdbc 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -304,22 +304,22 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) {
reg_t kFileIOOpen(EngineState *s, int argc, reg_t *argv) {
Common::String name = s->_segMan->getString(argv[0]);
-
- if (name.empty()) {
- // Happens many times during KQ1 (e.g. when typing something)
- debugC(kDebugLevelFile, "Attempted to open a file with an empty filename");
- return SIGNAL_REG;
- }
-
kFileOpenMode mode = (kFileOpenMode)argv[1].toUint16();
bool unwrapFilename = true;
- // SQ4 floppy prepends /\ to the filenames
+ // SQ4 floppy prepends /\ to the filenames, QFG4 import does too.
+ // Do this before the empty test to handle QFG4.
if (name.hasPrefix("/\\")) {
name.deleteChar(0);
name.deleteChar(0);
}
+ if (name.empty()) {
+ // Happens many times during KQ1 (e.g. when typing something)
+ debugC(kDebugLevelFile, "Attempted to open a file with an empty filename");
+ return SIGNAL_REG;
+ }
+
// SQ4 floppy attempts to update the savegame index file sq4sg.dir when
// deleting saved games. We don't use an index file for saving or loading,
// so just stop the game from modifying the file here in order to avoid
diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp
index b25f7f1f316..9aff3760990 100644
--- a/engines/sci/engine/klists.cpp
+++ b/engines/sci/engine/klists.cpp
@@ -869,6 +869,10 @@ reg_t kArrayCopy(EngineState *s, int argc, reg_t *argv) {
const uint16 sourceIndex = argv[3].toUint16();
const int16 count = argv[4].toSint16();
+ if (argv[2].isNull()) {
+ return argv[0];
+ }
+
if (!s->_segMan->isArray(argv[2])) {
// String copies may be made from static script data
SciArray source;
More information about the Scummvm-git-logs
mailing list