[llvm-commits] [llvm] r152662 - /llvm/trunk/lib/Support/MemoryBuffer.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Mar 13 13:18:43 PDT 2012
Author: akirtzidis
Date: Tue Mar 13 15:18:42 2012
New Revision: 152662
URL: http://llvm.org/viewvc/llvm-project?rev=152662&view=rev
Log:
Add a sanity check in MemoryBuffer::getOpenFile() to make sure we don't hang
if the passed in FileSize is inaccurate.
rdar://11034179
Modified:
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=152662&r1=152661&r2=152662&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Mar 13 15:18:42 2012
@@ -336,7 +336,11 @@
// 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;
}
More information about the llvm-commits
mailing list