1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

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
This commit is contained in:
Argyrios Kyrtzidis 2012-03-13 20:18:42 +00:00
parent 88de2712e2
commit 62c208980d

View File

@ -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;
}