-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] Prevent null pointer dereference in template deduction guide creation #97097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…creation This patch addresses static analyzer concerns where `TSI` could be dereferenced after being assigned a null value from `SubstType` in `ConvertConstructorToDeductionGuideTransform()`. The fixes now check null value of `TSI` after the call to `SubstType` and return `nullptr` to prevent potential null pointer dereferences when calling getTypeLoc() or getType() and ensure safe execution.
@llvm/pr-subscribers-clang Author: None (smanna12) ChangesThis patch addresses static analyzer concerns where The fixes now check null value of Full diff: https://github.com/llvm/llvm-project/pull/97097.diff 1 Files Affected:
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index e36ee2d5a46cf..9f4acbe5e6dd5 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2513,6 +2513,9 @@ struct ConvertConstructorToDeductionGuideTransform {
TSI = SemaRef.SubstType(TSI, OuterInstantiationArgs, Loc,
DeductionGuideName);
+ if (!TSI)
+ return nullptr;
+
FunctionProtoTypeLoc FPTL =
TSI->getTypeLoc().castAs<FunctionProtoTypeLoc>();
@@ -2523,6 +2526,9 @@ struct ConvertConstructorToDeductionGuideTransform {
if (NestedPattern)
TSI = SemaRef.SubstType(TSI, OuterInstantiationArgs, Loc,
DeclarationName());
+ if (!TSI)
+ return nullptr;
+
ParmVarDecl *NewParam =
ParmVarDecl::Create(SemaRef.Context, DC, Loc, Loc, nullptr,
TSI->getType(), TSI, SC_None, nullptr);
|
Thank you @antangelo for reviews! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/776 Here is the relevant piece of the build log for the reference:
|
…creation (llvm#97097) This patch addresses static analyzer concerns where `TSI` could be dereferenced after being assigned a null value from `SubstType` in `ConvertConstructorToDeductionGuideTransform()`. The fixes now check null value of `TSI` after the call to `SubstType` and return `nullptr` to prevent potential null pointer dereferences when calling getTypeLoc() or getType() and ensure safe execution.
This patch addresses static analyzer concerns where
TSI
could be dereferenced after being assigned a null value fromSubstType
inConvertConstructorToDeductionGuideTransform()
.The fixes now check null value of
TSI
after the call toSubstType
and returnnullptr
to prevent potential null pointer dereferences when calling getTypeLoc() or getType() and ensure safe execution.