Skip to content

Commit 0162df0

Browse files
authored
[Clang] Fix null pointer dereference in VisitUsingEnumDecl (llvm#97910)
This patch addresses static analyzer concern where TSI could be dereferenced after being assigned a null value from SubstType in clang::TemplateDeclInstantiator::VisitUsingEnumDecl(clang::UsingEnumDecl *). The fix now checks null value of TSI after the call to SubstType and return nullptr to prevent potential null pointer dereferences when calling UsingEnumDecl::Create() and ensures safe execution.
1 parent 4753f8e commit 0162df0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,6 +3420,10 @@ Decl *TemplateDeclInstantiator::VisitUsingEnumDecl(UsingEnumDecl *D) {
34203420

34213421
TypeSourceInfo *TSI = SemaRef.SubstType(D->getEnumType(), TemplateArgs,
34223422
D->getLocation(), D->getDeclName());
3423+
3424+
if (!TSI)
3425+
return nullptr;
3426+
34233427
UsingEnumDecl *NewUD =
34243428
UsingEnumDecl::Create(SemaRef.Context, Owner, D->getUsingLoc(),
34253429
D->getEnumLoc(), D->getLocation(), TSI);

0 commit comments

Comments
 (0)