aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorThanasis Antoniou2019-04-01 00:43:34 +0300
committerThanasis Antoniou2019-04-01 00:45:43 +0300
commit423dcd0a0116aa05894cc816fa266173e705ae63 (patch)
treeac8811914918a2d4769539195b6ac2ba96e3245e /engines
parent24057754ada89d3880a4194d11d99c7500f523dc (diff)
downloadscummvm-rg350-423dcd0a0116aa05894cc816fa266173e705ae63.tar.gz
scummvm-rg350-423dcd0a0116aa05894cc816fa266173e705ae63.tar.bz2
scummvm-rg350-423dcd0a0116aa05894cc816fa266173e705ae63.zip
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.
Diffstat (limited to 'engines')
-rw-r--r--engines/bladerunner/savefile.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/engines/bladerunner/savefile.cpp b/engines/bladerunner/savefile.cpp
index bc5227dbb4..b1e5aa3136 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