X Tutup
Skip to content

GOB: Fix SaveLoad_v7 initialization#6624

Merged
sdelamarre merged 1 commit intoscummvm:masterfrom
orgads:gob-saveload
May 19, 2025
Merged

GOB: Fix SaveLoad_v7 initialization#6624
sdelamarre merged 1 commit intoscummvm:masterfrom
orgads:gob-saveload

Conversation

@orgads
Copy link
Contributor

@orgads orgads commented May 16, 2025

The initialization order must match exactly the order of _saveFiles.

Discovered by GCC warning on release:

engines/gob/save/saveload_v7.cpp: In constructor 'Gob::SaveLoad_v7::SaveLoad_v7(Gob::GobEngine*, const char*)':
engines/gob/save/saveload_v7.cpp:1466:45: warning: iteration 9 invokes undefined behavior [-Waggressive-loop-optimizations]
 1466 |                 _saveFiles[index++].handler = _addy4GrundschuleHandler[i] = new FakeFileHandler(_vm);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
engines/gob/save/saveload_v7.cpp:1465:27: note: within this loop
 1465 |         for (int i = 0; i < 11; i++)
      |                         ~~^~~~

Amends 7e3ec46.

The initialization order must match exactly the order of _saveFiles.

Discovered by GCC warning on release:

engines/gob/save/saveload_v7.cpp: In constructor 'Gob::SaveLoad_v7::SaveLoad_v7(Gob::GobEngine*, const char*)':
engines/gob/save/saveload_v7.cpp:1466:45: warning: iteration 9 invokes undefined behavior [-Waggressive-loop-optimizations]
 1466 |                 _saveFiles[index++].handler = _addy4GrundschuleHandler[i] = new FakeFileHandler(_vm);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
engines/gob/save/saveload_v7.cpp:1465:27: note: within this loop
 1465 |         for (int i = 0; i < 11; i++)
      |                         ~~^~~~

Amends 7e3ec46.
@orgads
Copy link
Contributor Author

orgads commented May 19, 2025

ping

@sdelamarre
Copy link
Contributor

sdelamarre commented May 19, 2025

Oops, many thanks for catching this. This fix will invalidate some existing save files (that were created with a bad name), but fortunately the most important ones, like the score in Read/Count exercises were not in the scrambled parts.

@sdelamarre sdelamarre merged commit fd29564 into scummvm:master May 19, 2025
8 checks passed
@orgads orgads deleted the gob-saveload branch May 19, 2025 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup