schittir created this revision. schittir added reviewers: aaron.ballman, erichkeane. schittir added a project: clang. schittir requested review of this revision. Herald added a subscriber: cfe-commits.
Avoid nullptr dereferencing of 'Constraint'; NFC Klocwork static code analysis exposed this bug: Pointer 'SubExpr' returned from call to getSubExpr() function which may return NULL from 'cast_or_null<Expr>(Operand)', which will be dereferenced in the statement following it Add an assert on SubExpr to avoid nullptr dereferencing Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D108712 Files: clang/lib/CodeGen/MicrosoftCXXABI.cpp Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp =================================================================== --- clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -4348,6 +4348,7 @@ void MicrosoftCXXABI::emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) { const Expr *SubExpr = E->getSubExpr(); + assert(SubExpr && "SubExpr cannot be null"); QualType ThrowType = SubExpr->getType(); // The exception object lives on the stack and it's address is passed to the // runtime function.
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp =================================================================== --- clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -4348,6 +4348,7 @@ void MicrosoftCXXABI::emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) { const Expr *SubExpr = E->getSubExpr(); + assert(SubExpr && "SubExpr cannot be null"); QualType ThrowType = SubExpr->getType(); // The exception object lives on the stack and it's address is passed to the // runtime function.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits