Skip to content

Commit 8c5b701

Browse files
authored
[SYCL][NFC] Fix static code analysis concerns (#5189)
Found via a static-analysis tool: Suspicious dereference of pointer in function call before NULL check Inside checkAllowedSYCLInitializer() in SemaSYCL.cpp file: const Expr *Init = VD->getInit(); bool ValueDependent = Init->isValueDependent(); --> 'Init' is dereferenced by being passed as argument 0 to function "isValueDependent bool isConstantInit = Init && !ValueDependent && Init->isConstantInitializer(Context, false); --> 'Init' is checked for NULL here This patch adds NULL value checking for 'Init' expression. Signed-off-by: Soumi Manna <[email protected]>
1 parent a56c6e6 commit 8c5b701

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4148,7 +4148,7 @@ bool Sema::checkAllowedSYCLInitializer(VarDecl *VD) {
41484148
return true;
41494149

41504150
const Expr *Init = VD->getInit();
4151-
bool ValueDependent = Init->isValueDependent();
4151+
bool ValueDependent = Init && Init->isValueDependent();
41524152
bool isConstantInit =
41534153
Init && !ValueDependent && Init->isConstantInitializer(Context, false);
41544154
if (!VD->isConstexpr() && Init && !ValueDependent && !isConstantInit)

0 commit comments

Comments
 (0)