summaryrefslogtreecommitdiff
path: root/zen/file_io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zen/file_io.cpp')
-rwxr-xr-xzen/file_io.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/zen/file_io.cpp b/zen/file_io.cpp
index b4affd37..0c5ff490 100755
--- a/zen/file_io.cpp
+++ b/zen/file_io.cpp
@@ -140,7 +140,7 @@ size_t FileInput::read(void* buffer, size_t bytesToRead) //throw FileError, X; r
if (notifyUnbufferedIO_) notifyUnbufferedIO_(bytesRead); //throw X
if (bytesRead == 0) //end of file
- bytesToRead = memBuf_.size();
+ bytesToRead = std::min(bytesToRead, memBuf_.size());
}
std::copy(memBuf_.begin(), memBuf_.begin() + bytesToRead, static_cast<char*>(buffer));
@@ -185,9 +185,10 @@ FileOutput::FileOutput(const Zstring& filePath, AccessFlag access, const IOCallb
FileOutput::~FileOutput()
{
+ notifyUnbufferedIO_ = nullptr; //no call-backs during destruction!!!
try
{
- flushBuffers(); //throw FileError, X
+ flushBuffers(); //throw FileError, (X)
}
catch (...) { assert(false); }
}
bgstack15