[PATCH] D152194: [NFC][CLANG] Fix nullptr dereference issue found by static analyzer tool

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 6 06:22:46 PDT 2023


erichkeane added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:756
     if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType() ||
         ASTCtxt.canAssignObjCInterfaces(ReceiverObjectPtrType, TrackedType)) {
       const ObjCInterfaceDecl *InterfaceDecl = TrackedType->getInterfaceDecl();
----------------
Manna wrote:
> We are assigning: ReceiverObjectPtrType = nullptr return value from getAs.
> ```
> const auto *ReceiverObjectPtrType =
>       ReceiverType->getAs<ObjCObjectPointerType>();
> ```
> 
> Then we are dereferencing  nullptr ReceiverObjectPtrType when calling canAssignObjCInterfaces()
This isn't NFC, as `ReceiverObjectPtrType` is only used here.  If the `MessageExpr` `ReceiverKind` is not `Instance` or `Class`, we never dereference this.  So the declaration should be in this branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152194



More information about the cfe-commits mailing list