From 67d1a412267784d2d78d0f37e772a32b7b6129e7 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Wed, 9 Nov 2016 21:26:49 +0000 Subject: 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 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') 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 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: -- cgit v1.2.3