aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Support/MemoryBuffer.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp
index 4b15587db7..911a03f808 100644
--- a/lib/Support/MemoryBuffer.cpp
+++ b/lib/Support/MemoryBuffer.cpp
@@ -336,7 +336,11 @@ error_code MemoryBuffer::getOpenFile(int FD, const char *Filename,
// Error while reading.
return error_code(errno, posix_category());
}
- assert(NumRead != 0 && "fstat reported an invalid file size.");
+ if (NumRead == 0) {
+ assert(0 && "We got inaccurate FileSize value or fstat reported an "
+ "invalid file size.");
+ break;
+ }
BytesLeft -= NumRead;
BufPtr += NumRead;
}