mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-30 15:10:30 +00:00
[BitcodeReader] Check if we can create a null constant for type.
We cannot create null constants for certain types, e.g. VoidTy, FunctionTy or LabelTy. getNullValue asserts if we pass in an unsupported type. We should also check for opaque types, but I'm not sure how. This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14795. Reviewers: t.p.northover, jfb, vsk Reviewed By: vsk Tags: #llvm Differential Revision: https://reviews.llvm.org/D65897 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369557 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0fc3ded3ad
commit
47b49a52ae
@ -2377,6 +2377,8 @@ Error BitcodeReader::parseConstants() {
|
|||||||
CurTy = flattenPointerTypes(CurFullTy);
|
CurTy = flattenPointerTypes(CurFullTy);
|
||||||
continue; // Skip the ValueList manipulation.
|
continue; // Skip the ValueList manipulation.
|
||||||
case bitc::CST_CODE_NULL: // NULL
|
case bitc::CST_CODE_NULL: // NULL
|
||||||
|
if (CurTy->isVoidTy() || CurTy->isFunctionTy() || CurTy->isLabelTy())
|
||||||
|
return error("Invalid type for a constant null value");
|
||||||
V = Constant::getNullValue(CurTy);
|
V = Constant::getNullValue(CurTy);
|
||||||
break;
|
break;
|
||||||
case bitc::CST_CODE_INTEGER: // INTEGER: [intval]
|
case bitc::CST_CODE_INTEGER: // INTEGER: [intval]
|
||||||
|
6
test/Bitcode/invalid-type-for-null-constant.ll
Normal file
6
test/Bitcode/invalid-type-for-null-constant.ll
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
; Bitcode with a CST_CODE_NULL with void type.
|
||||||
|
|
||||||
|
; RUN: not llvm-dis %s.bc -o - 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: error: Invalid type for a constant null value
|
||||||
|
|
BIN
test/Bitcode/invalid-type-for-null-constant.ll.bc
Normal file
BIN
test/Bitcode/invalid-type-for-null-constant.ll.bc
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user