[Scummvm-git-logs] scummvm master -> 50d52b9d44e193c73abb002edf5817d9f4972dc5
phcoder
noreply at scummvm.org
Fri Jan 6 00:53:50 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:
50d52b9d44 SAGA: Correctly handle the case of missing patch file.
Commit: 50d52b9d44e193c73abb002edf5817d9f4972dc5
https://github.com/scummvm/scummvm/commit/50d52b9d44e193c73abb002edf5817d9f4972dc5
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-01-06T03:53:46+03:00
Commit Message:
SAGA: Correctly handle the case of missing patch file.
Changed paths:
engines/saga/resource.h
diff --git a/engines/saga/resource.h b/engines/saga/resource.h
index d54aa02e449..2e65dcd602a 100644
--- a/engines/saga/resource.h
+++ b/engines/saga/resource.h
@@ -44,27 +44,34 @@ private:
Common::SeekableReadStream *_patchFile;
const char *_fileName;
bool _deletePatchFile;
+ bool _patchFileOpened;
public:
- PatchData(const char *fileName): _fileName(fileName), _deletePatchFile(true), _patchFile(nullptr) {
+ PatchData(const char *fileName): _fileName(fileName), _deletePatchFile(true), _patchFile(nullptr), _patchFileOpened(false) {
}
- PatchData(Common::SeekableReadStream *patchFile, const char *fileName): _patchFile(patchFile), _fileName(fileName), _deletePatchFile(false) {
+ PatchData(Common::SeekableReadStream *patchFile, const char *fileName): _patchFile(patchFile), _fileName(fileName), _deletePatchFile(false), _patchFileOpened(true) {
}
Common::SeekableReadStream *getStream() {
- if (_patchFile)
+ if (_patchFileOpened)
return _patchFile;
Common::File *file = new Common::File();
- file->open(_fileName);
+ _patchFileOpened = true;
+ if (!file->open(_fileName)) {
+ _patchFile = nullptr;
+ delete file;
+ return nullptr;
+ }
_patchFile = file;
return _patchFile;
}
void closeStream() {
- if (_deletePatchFile) {
+ if (_deletePatchFile && _patchFileOpened) {
delete _patchFile;
_patchFile = nullptr;
+ _patchFileOpened = false;
}
}
More information about the Scummvm-git-logs
mailing list