diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 2eddc98d3..bc467acff 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -25,14 +25,28 @@ void FFmpeg_Decoder::fail(const std::string &msg) int FFmpeg_Decoder::readPacket(void *user_data, uint8_t *buf, int buf_size) { - Ogre::DataStreamPtr stream = static_cast(user_data)->mDataStream; - return stream->read(buf, buf_size); + try + { + Ogre::DataStreamPtr stream = static_cast(user_data)->mDataStream; + return stream->read(buf, buf_size); + } + catch (std::exception& e) + { + return 0; + } } int FFmpeg_Decoder::writePacket(void *user_data, uint8_t *buf, int buf_size) { - Ogre::DataStreamPtr stream = static_cast(user_data)->mDataStream; - return stream->write(buf, buf_size); + try + { + Ogre::DataStreamPtr stream = static_cast(user_data)->mDataStream; + return stream->write(buf, buf_size); + } + catch (std::exception& e) + { + return 0; + } } int64_t FFmpeg_Decoder::seek(void *user_data, int64_t offset, int whence) diff --git a/components/esm/esmreader.cpp b/components/esm/esmreader.cpp index 3c43d067f..bbe475ff7 100644 --- a/components/esm/esmreader.cpp +++ b/components/esm/esmreader.cpp @@ -123,7 +123,7 @@ std::string ESMReader::getHString() // Skip the following zero byte mCtx.leftRec--; char c; - mEsm->read(&c, 1); + getExact(&c, 1); return ""; } @@ -186,7 +186,7 @@ void ESMReader::getSubName() } // reading the subrecord data anyway. - mEsm->read(mCtx.subName.name, 4); + getExact(mCtx.subName.name, 4); mCtx.leftRec -= 4; } @@ -194,7 +194,7 @@ bool ESMReader::isEmptyOrGetName() { if (mCtx.leftRec) { - mEsm->read(mCtx.subName.name, 4); + getExact(mCtx.subName.name, 4); mCtx.leftRec -= 4; return false; } @@ -294,9 +294,16 @@ void ESMReader::getRecHeader(uint32_t &flags) void ESMReader::getExact(void*x, int size) { - int t = mEsm->read(x, size); - if (t != size) - fail("Read error"); + try + { + int t = mEsm->read(x, size); + if (t != size) + fail("Read error"); + } + catch (std::exception& e) + { + fail(std::string("Read error: ") + e.what()); + } } std::string ESMReader::getString(int size) diff --git a/extern/ogre-ffmpeg-videoplayer/videostate.cpp b/extern/ogre-ffmpeg-videoplayer/videostate.cpp index 9dac0bacd..0894499b2 100644 --- a/extern/ogre-ffmpeg-videoplayer/videostate.cpp +++ b/extern/ogre-ffmpeg-videoplayer/videostate.cpp @@ -175,13 +175,27 @@ void PacketQueue::clear() int VideoState::OgreResource_Read(void *user_data, uint8_t *buf, int buf_size) { Ogre::DataStreamPtr stream = static_cast(user_data)->stream; - return stream->read(buf, buf_size); + try + { + return stream->read(buf, buf_size); + } + catch (std::exception& e) + { + return 0; + } } int VideoState::OgreResource_Write(void *user_data, uint8_t *buf, int buf_size) { Ogre::DataStreamPtr stream = static_cast(user_data)->stream; - return stream->write(buf, buf_size); + try + { + return stream->write(buf, buf_size); + } + catch (std::exception& e) + { + return 0; + } } int64_t VideoState::OgreResource_Seek(void *user_data, int64_t offset, int whence)