[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

Tom Honermann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 12:22:21 PST 2022


tahonermann added inline comments.


================
Comment at: clang/lib/Sema/SemaInit.cpp:5824-5828
   // Handle default initialization.
   if (Kind.getKind() == InitializationKind::IK_Default) {
     TryDefaultInitialization(S, Entity, Kind, *this);
     return;
   }
----------------
schittir wrote:
> tahonermann wrote:
> > This block handles default initialization and unconditionally performs a return. I wonder if this effectively guarantees that `Initializer` is non-null if this block is not entered.
> Thank you for the review. I am trying to find an explicit connection between this block and `Initializer` being non-null, but it isn't clear to me yet. 
> How about adding the assert right after this block?
I think adding an `assert` here is a good thing to try. If any tests fail, then we'll know this isn't the right place. If no tests fail, then, well, the `assert` is good or we need more tests! ;)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139148/new/

https://reviews.llvm.org/D139148



More information about the cfe-commits mailing list