[BitcodeReader] Diagnose type mismatches with aliases

Bug found with AFL fuzz.

llvm-svn: 238895
This commit is contained in:
Filipe Cabecinhas 2015-06-03 01:30:13 +00:00
parent cc520bbd9a
commit 337bf6fd2c
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