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

Sindhu Chittireddy via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 12:02:54 PST 2022


schittir 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;
   }
----------------
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?


================
Comment at: clang/lib/Sema/SemaInit.cpp:5941
     if (allowObjCWritebackConversion &&
         tryObjCWritebackConversion(S, *this, Entity, Initializer)) {
       return;
----------------
tahonermann wrote:
> This use of `Initializer` is also questionable; `tryObjCWritebackConversion()` will unconditionally dereference it.
Indeed. This set of calls should be addressed too. 


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

https://reviews.llvm.org/D139148



More information about the cfe-commits mailing list