[llvm] r286394 - Make BitcodeReader::parseIdentificationBlock() robust to EOF
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 9 13:26:49 PST 2016
Author: mehdi_amini
Date: Wed Nov 9 15:26:49 2016
New Revision: 286394
URL: http://llvm.org/viewvc/llvm-project?rev=286394&view=rev
Log:
Make BitcodeReader::parseIdentificationBlock() robust to EOF
This method is particular: it iterates at the top-level and does
not have an enclosing block.
Modified:
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=286394&r1=286393&r2=286394&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Nov 9 15:26:49 2016
@@ -4347,6 +4347,12 @@ Expected<std::string> BitcodeReader::par
// 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:
More information about the llvm-commits
mailing list