From b435d0f4395448620e3e15411e635c102d915a2e Mon Sep 17 00:00:00 2001 From: Filipe Cabecinhas Date: Tue, 28 Apr 2015 20:18:47 +0000 Subject: Relax an assert when there's a type mismatch in forward references Summary: We don't seem to need to assert here, since this function's callers expect to get a nullptr on error. This way we don't assert on user input. Bug found with AFL fuzz. Reviewers: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9308 llvm-svn: 236027 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (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 35e98c017601..6656478754ee 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -794,7 +794,9 @@ Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, Type *Ty) { resize(Idx + 1); if (Value *V = ValuePtrs[Idx]) { - assert((!Ty || Ty == V->getType()) && "Type mismatch in value table!"); + // If the types don't match, it's invalid. + if (Ty && Ty != V->getType()) + return nullptr; return V; } -- cgit v1.2.3