From 3fae6fbf464ed842ac022fb9e2202a1d18f3f455 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 28 May 2003 02:06:53 +0000 Subject: added some missing checks for file being open before reading/writing svn-id: r8043 --- common/file.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') 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; -- cgit v1.2.3