summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-11-09 21:26:49 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-11-09 21:26:49 +0000
commit67d1a412267784d2d78d0f37e772a32b7b6129e7 (patch)
tree823ea8dd7f6ce796e9bec5827f6431cc525631e3 /llvm/lib/Bitcode
parentd43b7e8d1096544ec2c0c8473ba308b0e969a8a1 (diff)
downloadbcm5719-llvm-67d1a412267784d2d78d0f37e772a32b7b6129e7.tar.gz
bcm5719-llvm-67d1a412267784d2d78d0f37e772a32b7b6129e7.zip
Make BitcodeReader::parseIdentificationBlock() robust to EOF
This method is particular: it iterates at the top-level and does not have an enclosing block. llvm-svn: 286394
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 57b03e80fa6..23876ffcb99 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -4347,6 +4347,12 @@ Expected<std::string> BitcodeReader::parseIdentificationBlock() {
// We expect a number of well-defined blocks, though we don't necessarily
// need to understand them all.
while (true) {
+ // This loop iterates at the top-level: since there is no enclosing block
+ // we need to make sure we aren't at the end of the stream before calling
+ // advance, otherwise we'll get an error.
+ if (Stream.AtEndOfStream())
+ return Error::success();
+
BitstreamEntry Entry = Stream.advance();
switch (Entry.Kind) {
case BitstreamEntry::Error:
OpenPOWER on IntegriCloud