aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2014-12-23 21:46:20 +0200
committerFilippos Karapetis2014-12-23 21:46:20 +0200
commit78ba3e32466992ee7d01aabff493617a6401273e (patch)
tree0823f47e991d7992c184696126cab1ab21433b24 /engines
parente8cc098cd4303a959e69769eae2d37dd949d27d3 (diff)
downloadscummvm-rg350-78ba3e32466992ee7d01aabff493617a6401273e.tar.gz
scummvm-rg350-78ba3e32466992ee7d01aabff493617a6401273e.tar.bz2
scummvm-rg350-78ba3e32466992ee7d01aabff493617a6401273e.zip
ZVISION: Add error checking when loading in-game animations and videos
Diffstat (limited to 'engines')
-rw-r--r--engines/zvision/video/rlf_decoder.cpp14
-rw-r--r--engines/zvision/video/video.cpp7
2 files changed, 13 insertions, 8 deletions
diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp
index b798093869..76fd70cf35 100644
--- a/engines/zvision/video/rlf_decoder.cpp
+++ b/engines/zvision/video/rlf_decoder.cpp
@@ -39,9 +39,13 @@ RLFDecoder::~RLFDecoder() {
bool RLFDecoder::loadStream(Common::SeekableReadStream *stream) {
close();
- addTrack(new RLFVideoTrack(stream));
-
- return true;
+ // Check if the stream is valid
+ if (stream && !stream->err() && stream->readUint32BE() == MKTAG('F', 'E', 'L', 'R')) {
+ addTrack(new RLFVideoTrack(stream));
+ return true;
+ } else {
+ return false;
+ }
}
RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream)
@@ -81,10 +85,6 @@ RLFDecoder::RLFVideoTrack::~RLFVideoTrack() {
}
bool RLFDecoder::RLFVideoTrack::readHeader() {
- if (_readStream->readUint32BE() != MKTAG('F', 'E', 'L', 'R')) {
- return false;
- }
-
// Read the header
_readStream->readUint32LE(); // Size1
_readStream->readUint32LE(); // Unknown1
diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp
index 97fbd8721c..50a6fc136a 100644
--- a/engines/zvision/video/video.cpp
+++ b/engines/zvision/video/video.cpp
@@ -48,7 +48,12 @@ Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) {
error("Unknown suffix for animation %s", fileName.c_str());
Common::File *_file = getSearchManager()->openFile(tmpFileName);
- animation->loadStream(_file);
+ if (!_file)
+ error("Error opening %s", tmpFileName.c_str());
+
+ bool loaded = animation->loadStream(_file);
+ if (!loaded)
+ error("Error loading animation %s", tmpFileName.c_str());
return animation;
}