1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Fix a crash in the LL parser where it failed to validate that the pointer operand of a GEP was valid.

This manifested as an assertion failure in +Asserts builds, and a hard crash in -Asserts builds.  Found by fuzzing the LL parser.

llvm-svn: 230934
This commit is contained in:
Owen Anderson 2015-03-02 05:25:06 +00:00
parent c961d86cad
commit 93f8351a0a
2 changed files with 13 additions and 0 deletions

View File

@ -5458,6 +5458,8 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) {
return true;
Type *PtrTy = Ptr->getType();
if (!isa<SequentialType>(PtrTy))
return Error(Loc, "pointer type is not valid");
if (VectorType *VT = dyn_cast<VectorType>(PtrTy))
PtrTy = VT->getElementType();
if (Ty != cast<SequentialType>(PtrTy)->getElementType())

View File

@ -0,0 +1,11 @@
; RUN: not llvm-as < %s >/dev/null 2> %t
; RUN: FileCheck %s < %t
; Test the case of an invalid pointer type on a GEP
; CHECK: pointer type is not valid
define i32* @foo(i32 %a) {
%gep = getelementptr i32, i32 %a, i32 1
return i32* %gep
}