From 84e342acd7399934eb85eb86568dcddb0021b798 Mon Sep 17 00:00:00 2001 From: Ryan Styrczula Date: Tue, 14 Jul 2020 10:39:18 -0400 Subject: [PATCH] DefaultIOStream: Remove assert on empty count fwrite() is valid to call with a 0 count, and will simply return 0. See: https://en.cppreference.com/w/cpp/io/c/fwrite http://www.cplusplus.com/reference/cstdio/fwrite/ There are code paths where StreamWriter will call Tell(), which calls Flush(), which calls Write(buffer.data(), 1, buffer.size()). This can happen when nothing has yet been written to the buffer, so size is 0. --- code/Common/DefaultIOStream.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp index 65edd1bdd..32f47ab07 100644 --- a/code/Common/DefaultIOStream.cpp +++ b/code/Common/DefaultIOStream.cpp @@ -100,7 +100,6 @@ size_t DefaultIOStream::Write(const void *pvBuffer, size_t pCount) { ai_assert(nullptr != pvBuffer); ai_assert(0 != pSize); - ai_assert(0 != pCount); return (mFile ? ::fwrite(pvBuffer, pSize, pCount, mFile) : 0); }