diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-13 20:18:42 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-13 20:18:42 +0000 |
commit | 3dc531ef4434d2ac07f8e7f8ad1d306b6410386d (patch) | |
tree | d6147bbeb75dd0da08eeaa24d285459a5050f004 /llvm/lib/Support | |
parent | d6f716ab2a1cb2f5ff5d86d304a5672498772ff4 (diff) | |
download | bcm5719-llvm-3dc531ef4434d2ac07f8e7f8ad1d306b6410386d.tar.gz bcm5719-llvm-3dc531ef4434d2ac07f8e7f8ad1d306b6410386d.zip |
Add a sanity check in MemoryBuffer::getOpenFile() to make sure we don't hang
if the passed in FileSize is inaccurate.
rdar://11034179
llvm-svn: 152662
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/MemoryBuffer.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp index 4b15587db7a..911a03f8088 100644 --- a/llvm/lib/Support/MemoryBuffer.cpp +++ b/llvm/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; } |