[Scummvm-git-logs] scummvm master -> 423dcd0a0116aa05894cc816fa266173e705ae63

antoniou79 antoniou at cti.gr
Sun Mar 31 23:59:06 CEST 2019


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:
423dcd0a01 BLADERUNNER: Prevent lockup when save file is missing data


Commit: 423dcd0a0116aa05894cc816fa266173e705ae63
    https://github.com/scummvm/scummvm/commit/423dcd0a0116aa05894cc816fa266173e705ae63
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2019-04-01T00:45:43+03:00

Commit Message:
BLADERUNNER: Prevent lockup when save file is missing data

Missing thumbnail data was causing a lockup on mouse-over

Still working on debugging why these corrupted save files may be created -- (Game_Over()) autosaves.

Changed paths:
    engines/bladerunner/savefile.cpp


diff --git a/engines/bladerunner/savefile.cpp b/engines/bladerunner/savefile.cpp
index bc5227d..b1e5aa3 100644
--- a/engines/bladerunner/savefile.cpp
+++ b/engines/bladerunner/savefile.cpp
@@ -99,7 +99,6 @@ void SaveFileManager::remove(const Common::String &target, int slot) {
 
 bool SaveFileManager::readHeader(Common::SeekableReadStream &in, SaveFileHeader &header, bool skipThumbnail) {
 	SaveFileReadStream s(in);
-
 	if (s.readUint32BE() != kTag) {
 		warning("No header found in save file");
 		return false;
@@ -121,11 +120,24 @@ bool SaveFileManager::readHeader(Common::SeekableReadStream &in, SaveFileHeader
 
 	header._thumbnail = nullptr;
 
+	// Early check of possible corrupted save file (missing thumbnail and other data)
+	int32 pos = s.pos();
+	int32 sizeOfSaveFile = s.size();
+	if (sizeOfSaveFile > 0 && sizeOfSaveFile < (int32) (pos + 4 + kThumbnailSize)) {
+		warning("Unexpected end of save file %s (%02d:%02d %02d/%02d/%04d) reached. Size of file was: %d bytes",
+		         header._name.c_str(),
+		         header._hour,
+		         header._minute,
+		         header._day,
+		         header._month,
+		         header._year,
+		         sizeOfSaveFile);
+		return false;
+	}
+
 	if (!skipThumbnail) {
 		header._thumbnail = new Graphics::Surface(); // freed by ScummVM's smartptr
 
-		int32 pos = s.pos();
-
 		s.skip(4); //skip size;
 
 		void *thumbnailData = malloc(kThumbnailSize); // freed by ScummVM's smartptr





More information about the Scummvm-git-logs mailing list