Skip to content

Commit 5162fde

Browse files
authoredDec 20, 2024
[webkit.UncountedLambdaCapturesChecker] Fix a nullptr deference. (#120702)
Added a nullptr check.
1 parent 3bf91ad commit 5162fde

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
 

‎clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ class UncountedLambdaCapturesChecker
155155
if (!Init)
156156
return nullptr;
157157
TempExpr = dyn_cast<CXXBindTemporaryExpr>(Init->IgnoreParenCasts());
158+
if (!TempExpr)
159+
return nullptr;
158160
return dyn_cast_or_null<LambdaExpr>(TempExpr->getSubExpr());
159161
}
160162

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.UncountedLambdaCapturesChecker -verify %s
2+
// expected-no-diagnostics
3+
4+
struct Foo {
5+
int x;
6+
int y;
7+
Foo(int x, int y) : x(x) , y(y) { }
8+
~Foo() { }
9+
};
10+
11+
Foo bar(const Foo&);
12+
void foo() {
13+
int x = 7;
14+
int y = 5;
15+
bar(Foo(x, y));
16+
}

0 commit comments

Comments
 (0)
Please sign in to comment.