mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-20 10:24:12 +00:00
[Bitcode] Diagnose errors instead of asserting from bad input
Eventually we can make some of these pass the error along to the caller. Reports a fatal error if: We find an invalid abbrev record We try to get an invalid abbrev number We can't fill the current word due to an EOF Fixed an invalid bitcode test to check for output with FileCheck Bugs found with afl-fuzz git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226986 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -315,7 +315,8 @@ public:
|
||||
}
|
||||
|
||||
void fillCurWord() {
|
||||
assert(Size == 0 || NextChar < (unsigned)Size);
|
||||
if (Size != 0 && NextChar >= (unsigned)Size)
|
||||
report_fatal_error("Unexpected end of file");
|
||||
|
||||
// Read the next word from the stream.
|
||||
uint8_t Array[sizeof(word_t)] = {0};
|
||||
@ -490,11 +491,11 @@ private:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
public:
|
||||
|
||||
/// Return the abbreviation for the specified AbbrevId.
|
||||
const BitCodeAbbrev *getAbbrev(unsigned AbbrevID) {
|
||||
unsigned AbbrevNo = AbbrevID-bitc::FIRST_APPLICATION_ABBREV;
|
||||
assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!");
|
||||
unsigned AbbrevNo = AbbrevID - bitc::FIRST_APPLICATION_ABBREV;
|
||||
if (AbbrevNo >= CurAbbrevs.size())
|
||||
report_fatal_error("Invalid abbrev number");
|
||||
return CurAbbrevs[AbbrevNo].get();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user