Permalink
Comparing changes
Open a pull request
- 3 commits
- 2 files changed
- 0 commit comments
- 1 contributor
Commits on Apr 18, 2018
Commit 00e59a3 introduced a change to savegame handling which results in savegame thumbnails only being loaded when necessary. ZVISION's readSaveGameHeader() doesn't under all circumstances initialize the thumbnail pointer and 00e59a3 failed to remove an otherwise unnecessary delete which resulted in the uninitialized thumbnail pointer being passed to delete (UB). Thanks to eriktorbjorn for noticing.
Unified
Split
Showing
with
14 additions
and 14 deletions.
- +5 −5 engines/sword25/gfx/graphicengine.cpp
- +9 −9 engines/zvision/file/save_manager.cpp
| @@ -362,7 +362,7 @@ void GraphicEngine::updateLastFrameDuration() { | ||
| } | ||
|
|
||
| bool GraphicEngine::saveThumbnailScreenshot(const Common::String &filename) { | ||
| // Note: In ScumMVM, rather than saivng the thumbnail to a file, we store it in memory | ||
| // Note: In ScummVM, rather than saving the thumbnail to a file, we store it in memory | ||
| // until needed when creating savegame files | ||
| delete _thumbnail; | ||
|
|
||
| @@ -373,10 +373,10 @@ bool GraphicEngine::saveThumbnailScreenshot(const Common::String &filename) { | ||
|
|
||
| void GraphicEngine::ARGBColorToLuaColor(lua_State *L, uint color) { | ||
| lua_Number components[4] = { | ||
| (lua_Number)((color >> 16) & 0xff), // Red | ||
| (lua_Number)((color >> 8) & 0xff), // Green | ||
| (lua_Number)(color & 0xff), // Blue | ||
| (lua_Number)(color >> 24), // Alpha | ||
| (lua_Number)((color >> 16) & 0xff), // Red | ||
| (lua_Number)((color >> 8) & 0xff), // Green | ||
| (lua_Number)( color & 0xff), // Blue | ||
| (lua_Number)( color >> 24), // Alpha | ||
| }; | ||
|
|
||
| lua_newtable(L); | ||
| @@ -162,8 +162,6 @@ Common::Error SaveManager::loadGame(int slot) { | ||
| scriptManager->deserialize(saveFile); | ||
|
|
||
| delete saveFile; | ||
| if (header.thumbnail) | ||
| delete header.thumbnail; | ||
|
|
||
| if (_engine->getGameId() == GID_NEMESIS && scriptManager->getCurrentLocation() == "tv2f") { | ||
| // WORKAROUND for script bug #6793: location tv2f (stairs) has two states: | ||
| @@ -190,16 +188,19 @@ Common::Error SaveManager::loadGame(int slot) { | ||
| } | ||
|
|
||
| bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header, bool skipThumbnail) { | ||
| header.saveYear = 0; | ||
| header.saveMonth = 0; | ||
| header.saveDay = 0; | ||
| header.saveHour = 0; | ||
| header.saveMinutes = 0; | ||
| header.saveName.clear(); | ||
| header.thumbnail = nullptr; | ||
| header.version = 0; | ||
|
|
||
| uint32 tag = in->readUint32BE(); | ||
| // Check if it's original savegame than fill header structure | ||
| if (tag == MKTAG('Z', 'N', 'S', 'G')) { | ||
| header.saveYear = 0; | ||
| header.saveMonth = 0; | ||
| header.saveDay = 0; | ||
| header.saveHour = 0; | ||
| header.saveMinutes = 0; | ||
| header.saveName = "Original Save"; | ||
| header.thumbnail = NULL; | ||
| header.version = SAVE_ORIGINAL; | ||
| in->seek(-4, SEEK_CUR); | ||
| return true; | ||
| @@ -226,7 +227,6 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea | ||
| } | ||
|
|
||
| // Read in the save name | ||
| header.saveName.clear(); | ||
| char ch; | ||
| while ((ch = (char)in->readByte()) != '\0') | ||
| header.saveName += ch; | ||