diff options
author | Max Horn | 2003-05-28 02:06:53 +0000 |
---|---|---|
committer | Max Horn | 2003-05-28 02:06:53 +0000 |
commit | 3fae6fbf464ed842ac022fb9e2202a1d18f3f455 (patch) | |
tree | 9d9d6fea1cd0096936a970d8506df87c4c5bf099 /common | |
parent | e9d422a39c57d02d122714800e1dfdba97a87c6a (diff) | |
download | scummvm-rg350-3fae6fbf464ed842ac022fb9e2202a1d18f3f455.tar.gz scummvm-rg350-3fae6fbf464ed842ac022fb9e2202a1d18f3f455.tar.bz2 scummvm-rg350-3fae6fbf464ed842ac022fb9e2202a1d18f3f455.zip |
added some missing checks for file being open before reading/writing
svn-id: r8043
Diffstat (limited to 'common')
-rw-r--r-- | common/file.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/common/file.cpp b/common/file.cpp index 788b2b57cb..0b9dbbef68 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -230,6 +230,11 @@ uint32 File::read(void *ptr, uint32 len) { byte File::readByte() { byte b; + if (_handle == NULL) { + error("File is not open!"); + return 0; + } + if (fread(&b, 1, 1, _handle) != 1) { clearerr(_handle); _ioFailed = true; @@ -293,6 +298,10 @@ uint32 File::write(void *ptr, uint32 len) { void File::writeByte(byte value) { value ^= _encbyte; + if (_handle == NULL) { + error("File is not open!"); + } + if (fwrite(&value, 1, 1, _handle) != 1) { clearerr(_handle); _ioFailed = true; |