[BitcodeReader] Diagnose type mismatches with aliases

Bug found with AFL fuzz.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238895 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Filipe Cabecinhas 2015-06-03 01:30:13 +00:00
parent 1a2a0ee8a0
commit a3a2cab504
3 changed files with 11 additions and 3 deletions

View File

@ -2065,9 +2065,12 @@ std::error_code BitcodeReader::ResolveGlobalAndAliasInits() {
if (ValID >= ValueList.size()) {
AliasInits.push_back(AliasInitWorklist.back());
} else {
if (Constant *C = dyn_cast_or_null<Constant>(ValueList[ValID]))
AliasInitWorklist.back().first->setAliasee(C);
else
if (Constant *C = dyn_cast_or_null<Constant>(ValueList[ValID])) {
GlobalAlias *Alias = AliasInitWorklist.back().first;
if (C->getType() != Alias->getType())
return Error("Alias and aliasee types don't match");
Alias->setAliasee(C);
} else
return Error("Expected a constant");
}
AliasInitWorklist.pop_back();

Binary file not shown.

View File

@ -197,3 +197,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-length.bc 2>&1 | \
RUN: FileCheck --check-prefix=VECTOR-LENGTH %s
VECTOR-LENGTH: Invalid vector length
RUN: not llvm-dis -disable-output %p/Inputs/invalid-alias-type-mismatch.bc 2>&1 | \
RUN: FileCheck --check-prefix=ALIAS-TYPE-MISMATCH %s
ALIAS-TYPE-MISMATCH: Alias and aliasee types don't match