[clang] [clang][dataflow] Fix two null pointer dereferences in `getMemberForAccessor()`. (PR #66742)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 18 23:45:41 PDT 2023


================
@@ -289,11 +289,14 @@ static void insertIfFunction(const Decl &D,
 }
 
 static MemberExpr *getMemberForAccessor(const CXXMemberCallExpr &C) {
+  if (!C.getMethodDecl())
+    return nullptr;
   auto *Body = dyn_cast_or_null<CompoundStmt>(C.getMethodDecl()->getBody());
   if (!Body || Body->size() != 1)
     return nullptr;
   if (auto *RS = dyn_cast<ReturnStmt>(*Body->body_begin()))
-    return dyn_cast<MemberExpr>(RS->getRetValue()->IgnoreParenImpCasts());
+    if (RS->getRetValue() != nullptr)
----------------
hokein wrote:

nit: `if (auto* ReturnValue = RS->getRetValue())` 

https://github.com/llvm/llvm-project/pull/66742


More information about the cfe-commits mailing list