Skip to content

Commit 8781944

Browse files
committed
[analyzer] GenericTaint: Don't expect CallEvent to always have a Decl.
This isn't the case when the callee is completely unknown, eg. when it is a symbolic function pointer.
1 parent f5a812c commit 8781944

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ class GenericTaintChecker : public Checker<check::PreCall, check::PostCall> {
110110

111111
static Optional<FunctionData> create(const CallEvent &Call,
112112
const CheckerContext &C) {
113-
assert(Call.getDecl());
113+
if (!Call.getDecl())
114+
return None;
115+
114116
const FunctionDecl *FDecl = Call.getDecl()->getAsFunction();
115117
if (!FDecl || (FDecl->getKind() != Decl::Function &&
116118
FDecl->getKind() != Decl::CXXMethod))

clang/test/Analysis/taint-generic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,7 @@ void testConfigurationSinks() {
390390
mySink(1, 2, x);
391391
// expected-warning@-1 {{Untrusted data is passed to a user-defined sink}}
392392
}
393+
394+
void testUnknownFunction(void (*foo)(void)) {
395+
foo(); // no-crash
396+
}

0 commit comments

Comments
 (0)