Browse Source

Fix crash when reading 0 bytes

- This is a valid option so crash shall not happen
Kim Kulling 4 years ago
parent
commit
6abdd0cd3e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      code/Common/DefaultIOStream.cpp

+ 4 - 2
code/Common/DefaultIOStream.cpp

@@ -90,10 +90,12 @@ DefaultIOStream::~DefaultIOStream() {
 size_t DefaultIOStream::Read(void *pvBuffer,
         size_t pSize,
         size_t pCount) {
+    if (0 == pCount) {
+        return 0;
+    }
     ai_assert(nullptr != pvBuffer);
     ai_assert(0 != pSize);
-    ai_assert(0 != pCount);
-
+    
     return (mFile ? ::fread(pvBuffer, pSize, pCount, mFile) : 0);
 }