Skip to content

Commit 37af81f

Browse files
authored
[Clang][Sema] Add a nullptr check in template name (#162377)
Static analysis flagged that when calling ActOnTemplateName, `S` can be a `nullptr` and we call `isTemplateName` which unconditionally dereferences the `S` argument at some point. I added a `nullptr` check to assure we don't dereference `S` in `isTemplateName` if it is a `nullptr`.
1 parent 0ca23a3 commit 37af81f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
318318
}
319319
}
320320

321-
if (isPackProducingBuiltinTemplateName(Template) &&
321+
if (isPackProducingBuiltinTemplateName(Template) && S &&
322322
S->getTemplateParamParent() == nullptr)
323323
Diag(Name.getBeginLoc(), diag::err_builtin_pack_outside_template) << TName;
324324
// Recover by returning the template, even though we would never be able to

0 commit comments

Comments
 (0)