Skip to content

Commit 28b753b

Browse files
authored
[Clang][NFC] Add nullptr check in InitializationSequence::InitializeFrom (#143067)
Static analysis flagged that Var could be nullptr but we were not checking in the branch and unconditionally dereferences the pointer. Note, code was added by 576161c
1 parent 339797d commit 28b753b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/lib/Sema/SemaInit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6620,7 +6620,7 @@ void InitializationSequence::InitializeFrom(Sema &S,
66206620
// initializer present. However, we only do this for structure types, not
66216621
// union types, because an unitialized field in a union is generally
66226622
// reasonable, especially in C where unions can be used for type punning.
6623-
if (!Initializer && !Rec->isUnion() && !Rec->isInvalidDecl()) {
6623+
if (Var && !Initializer && !Rec->isUnion() && !Rec->isInvalidDecl()) {
66246624
if (const FieldDecl *FD = getConstField(Rec)) {
66256625
unsigned DiagID = diag::warn_default_init_const_field_unsafe;
66266626
if (Var->getStorageDuration() == SD_Static ||

0 commit comments

Comments
 (0)