From 1c0b496636bb76a56fa4606f9f1f6bc41d5f6163 Mon Sep 17 00:00:00 2001 From: Filipe Cabecinhas Date: Wed, 27 May 2015 01:05:40 +0000 Subject: [PATCH] [BitcodeReader] Change assert to report_fatal_error It can be triggered by user input. Bug found with AFL fuzz. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238272 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.cpp | 3 ++- .../Inputs/invalid-fwdref-type-mismatch-2.bc | Bin 0 -> 617 bytes test/Bitcode/invalid.test | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/Bitcode/Inputs/invalid-fwdref-type-mismatch-2.bc diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 95cf51f1419..f6d5ccc1a59 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -785,7 +785,8 @@ Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, resize(Idx + 1); if (Value *V = ValuePtrs[Idx]) { - assert(Ty == V->getType() && "Type mismatch in constant table!"); + if (Ty != V->getType()) + report_fatal_error("Type mismatch in constant table!"); return cast(V); } diff --git a/test/Bitcode/Inputs/invalid-fwdref-type-mismatch-2.bc b/test/Bitcode/Inputs/invalid-fwdref-type-mismatch-2.bc new file mode 100644 index 0000000000000000000000000000000000000000..8e38340eedea20ee424501a3217b4980fd350548 GIT binary patch literal 617 zcmZ>AK5$Qwhk+rFfq{X$Nr8b0NDBcmd!zD1#}h1`Yyw7>lNeigR9QJB}F$U~Vl5k}h%XN#7@Jx&eml@;v8GYWa0 zG4Q_?;QP|RXUyXycj%z(xrH)m2CQIZ&C+L>ZBIDc_AuK5%_vl0U;vpXwn3rS#U+?k zM&1 | \ +RUN: FileCheck --check-prefix=FWDREF-TYPE-MISMATCH %s + +FWDREF-TYPE-MISMATCH: Type mismatch in constant table! + RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-element-type.bc 2>&1 | \ RUN: FileCheck --check-prefix=ELEMENT-TYPE %s RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-element-type.bc 2>&1 | \ -- 2.34.1