llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: None (smanna12) <details> <summary>Changes</summary> The issue arises in the assert statement. The code asserts that either isSuperReceiver && Loc.isValid() is true or receiverTypeInfo is not null. However, the subsequent line (return BuildClassMessage(...)) dereferences receiverTypeInfo without explicitly checking if it’s null. The fix involves ensuring that the receiverTypeInfo pointer is not null before dereferencing it. By adding a null check for receiverTypeInfo, we prevent potential undefined behavior due to null pointer dereference. --- Full diff: https://github.com/llvm/llvm-project/pull/90482.diff 1 Files Affected: - (modified) clang/lib/Sema/SemaExprObjC.cpp (+6-4) ``````````diff diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index b13a9d426983b7..bdc16687e86dce 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -2440,10 +2440,12 @@ ExprResult Sema::BuildClassMessageImplicit(QualType ReceiverType, assert(((isSuperReceiver && Loc.isValid()) || receiverTypeInfo) && "Either the super receiver location needs to be valid or the receiver " "needs valid type source information"); - return BuildClassMessage(receiverTypeInfo, ReceiverType, - /*SuperLoc=*/isSuperReceiver ? Loc : SourceLocation(), - Sel, Method, Loc, Loc, Loc, Args, - /*isImplicit=*/true); + if (receiverTypeInfo) { + return BuildClassMessage(receiverTypeInfo, ReceiverType, + /*SuperLoc=*/isSuperReceiver ? Loc : SourceLocation(), + Sel, Method, Loc, Loc, Loc, Args, + /*isImplicit=*/true); + } } static void applyCocoaAPICheck(Sema &S, const ObjCMessageExpr *Msg, `````````` </details> https://github.com/llvm/llvm-project/pull/90482 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits