mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-02 21:17:17 +00:00
Make sure that isValidElementType(Type) before calling {Array,Struct}Type::get(Type)
Bug found with AFL fuzz. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236073 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1474,7 +1474,8 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
|
||||
case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
|
||||
if (Record.size() < 2)
|
||||
return Error("Invalid record");
|
||||
if ((ResultTy = getTypeByID(Record[1])))
|
||||
if ((ResultTy = getTypeByID(Record[1])) &&
|
||||
StructType::isValidElementType(ResultTy))
|
||||
ResultTy = ArrayType::get(ResultTy, Record[0]);
|
||||
else
|
||||
return Error("Invalid type");
|
||||
@@ -1482,7 +1483,8 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
|
||||
case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty]
|
||||
if (Record.size() < 2)
|
||||
return Error("Invalid record");
|
||||
if ((ResultTy = getTypeByID(Record[1])))
|
||||
if ((ResultTy = getTypeByID(Record[1])) &&
|
||||
StructType::isValidElementType(ResultTy))
|
||||
ResultTy = VectorType::get(ResultTy, Record[0]);
|
||||
else
|
||||
return Error("Invalid type");
|
||||
|
Reference in New Issue
Block a user