mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-27 15:57:30 +00:00
Make sure that isValidElementType(Type) before calling {Array,Struct}Type::get(Type)
Bug found with AFL fuzz. llvm-svn: 236073
This commit is contained in:
parent
09ffd9d1aa
commit
535f776116
@ -1474,7 +1474,8 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
|
|||||||
case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
|
case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
|
||||||
if (Record.size() < 2)
|
if (Record.size() < 2)
|
||||||
return Error("Invalid record");
|
return Error("Invalid record");
|
||||||
if ((ResultTy = getTypeByID(Record[1])))
|
if ((ResultTy = getTypeByID(Record[1])) &&
|
||||||
|
StructType::isValidElementType(ResultTy))
|
||||||
ResultTy = ArrayType::get(ResultTy, Record[0]);
|
ResultTy = ArrayType::get(ResultTy, Record[0]);
|
||||||
else
|
else
|
||||||
return Error("Invalid type");
|
return Error("Invalid type");
|
||||||
@ -1482,7 +1483,8 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
|
|||||||
case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty]
|
case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty]
|
||||||
if (Record.size() < 2)
|
if (Record.size() < 2)
|
||||||
return Error("Invalid record");
|
return Error("Invalid record");
|
||||||
if ((ResultTy = getTypeByID(Record[1])))
|
if ((ResultTy = getTypeByID(Record[1])) &&
|
||||||
|
StructType::isValidElementType(ResultTy))
|
||||||
ResultTy = VectorType::get(ResultTy, Record[0]);
|
ResultTy = VectorType::get(ResultTy, Record[0]);
|
||||||
else
|
else
|
||||||
return Error("Invalid type");
|
return Error("Invalid type");
|
||||||
|
BIN
test/Bitcode/Inputs/invalid-array-element-type.bc
Normal file
BIN
test/Bitcode/Inputs/invalid-array-element-type.bc
Normal file
Binary file not shown.
BIN
test/Bitcode/Inputs/invalid-vector-element-type.bc
Normal file
BIN
test/Bitcode/Inputs/invalid-vector-element-type.bc
Normal file
Binary file not shown.
@ -98,3 +98,10 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-fwdref-type-mismatch.bc 2>&1
|
|||||||
RUN: FileCheck --check-prefix=FWDREF-TYPE %s
|
RUN: FileCheck --check-prefix=FWDREF-TYPE %s
|
||||||
|
|
||||||
FWDREF-TYPE: Invalid record
|
FWDREF-TYPE: Invalid record
|
||||||
|
|
||||||
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-element-type.bc 2>&1 | \
|
||||||
|
RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
|
||||||
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-element-type.bc 2>&1 | \
|
||||||
|
RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
|
||||||
|
|
||||||
|
ELEMENT-TYPE: Invalid type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user