OSDN Git Service
(root)
/
android-x86
/
external-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e4c972d
)
Add a sanity check in MemoryBuffer::getOpenFile() to make sure we don't hang
author
Argyrios Kyrtzidis
<akyrtzi@gmail.com>
Tue, 13 Mar 2012 20:18:42 +0000
(20:18 +0000)
committer
Argyrios Kyrtzidis
<akyrtzi@gmail.com>
Tue, 13 Mar 2012 20:18:42 +0000
(20:18 +0000)
if the passed in FileSize is inaccurate.
rdar://
11034179
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152662
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/Support/MemoryBuffer.cpp
patch
|
blob
|
history
diff --git
a/lib/Support/MemoryBuffer.cpp
b/lib/Support/MemoryBuffer.cpp
index
4b15587
..
911a03f
100644
(file)
--- 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;
}