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
This commit is contained in:
Filipe Cabecinhas 2015-04-28 20:18:47 +00:00
parent e3ff9305cd
commit b435d0f439
3 changed files with 8 additions and 1 deletions

View File

@ -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;
}

View File

@ -93,3 +93,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-non-vector-shufflevector.bc
RUN: FileCheck --check-prefix=INVALID-TYPE %s
INVALID-TYPE: Invalid type for value
RUN: not llvm-dis -disable-output %p/Inputs/invalid-fwdref-type-mismatch.bc 2>&1 | \
RUN: FileCheck --check-prefix=FWDREF-TYPE %s
FWDREF-TYPE: Invalid record