Commit 823f2b2
authored
[SYCL][NFC] Fix bug with dereference null return value (#7294)
Reported by static analyzer tool:
Dereference null return value
If the function actually returns a null value, a null pointer
dereference will occur.
In <unnamed>::SyclKernelPointerHandler::leaveArray(clang::FieldDecl *,
clang::QualType, clang::QualType): Return value of function which
returns null is dereferenced without checking
bool leaveArray(FieldDecl *FD, QualType ArrayTy, QualType ET) final {
QualType ModifiedArrayElement =
ModifiedArrayElementsOrArray.pop_back_val();
// returned_null: getAsConstantArrayType returns nullptr (checked 73 out
of 88 times).
// var_assigned: Assigning: CAT = nullptr return value from
getAsConstantArrayType.
const ConstantArrayType *CAT =
SemaRef.getASTContext().getAsConstantArrayType(ArrayTy);
// Dereference null return value (NULL_RETURNS)
// dereference: Dereferencing a pointer that might be nullptr CAT when
calling getSizeExpr.
QualType ModifiedArray = SemaRef.getASTContext().getConstantArrayType(
ModifiedArrayElement, CAT->getSize(),
const_cast<Expr *>(CAT->getSizeExpr()), CAT->getSizeModifier(),
CAT->getIndexTypeCVRQualifiers());
This patch adds assert to resolve the bug.
Signed-off-by: Soumi Manna <[email protected]>
Signed-off-by: Soumi Manna <[email protected]>1 parent 998fd91 commit 823f2b2
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2087 | 2087 | | |
2088 | 2088 | | |
2089 | 2089 | | |
| 2090 | + | |
2090 | 2091 | | |
2091 | 2092 | | |
2092 | 2093 | | |
| |||
0 commit comments