forked from OSchip/llvm-project
[analyzer] Fix crash in NullabilityChecker calling block with too few arguments
Fix a crash when checking parameter nullability on a block invocation with fewer arguments than the block declaration requires. rdar://problem/29237566 llvm-svn: 286901
This commit is contained in:
parent
aaa06fa486
commit
e4224cc9f7
|
@ -679,9 +679,10 @@ void NullabilityChecker::checkPreCall(const CallEvent &Call,
|
|||
if (Param->isParameterPack())
|
||||
break;
|
||||
|
||||
const Expr *ArgExpr = nullptr;
|
||||
if (Idx < Call.getNumArgs())
|
||||
ArgExpr = Call.getArgExpr(Idx);
|
||||
if (Idx >= Call.getNumArgs())
|
||||
break;
|
||||
|
||||
const Expr *ArgExpr = Call.getArgExpr(Idx);
|
||||
auto ArgSVal = Call.getArgSVal(Idx++).getAs<DefinedOrUnknownSVal>();
|
||||
if (!ArgSVal)
|
||||
continue;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core,nullability -verify %s
|
||||
|
||||
void it_takes_two(int a, int b);
|
||||
void function_pointer_arity_mismatch() {
|
||||
void(*fptr)() = it_takes_two;
|
||||
fptr(1); // no-crash expected-warning {{Function taking 2 arguments is called with less (1)}}
|
||||
}
|
||||
|
||||
void block_arity_mismatch() {
|
||||
void(^b)() = ^(int a, int b) { }; // no-crash
|
||||
b(1);
|
||||
}
|
Loading…
Reference in New Issue