[SERVER-39303] Coverity analysis defect 105263: Dereference after null check Created: 31/Jan/19  Updated: 29/Oct/23  Resolved: 26/Feb/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.0.7, 4.1.9

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Mira Carey
Resolution: Fixed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0
Sprint: Service Arch 2019-03-11
Participants:

 Description   

Pointer is checked against null but then dereferenced anyway

Defect 105263 (STATIC_C)
Checker FORWARD_NULL (subcategory none)
File: /src/mongo/db/service_context.cpp
Function mongo::ServiceContext::OperationContextDeleter::operator ()(mongo::OperationContext *) const
/src/mongo/db/service_context.cpp, line: 261
Comparing "client" to null implies that "client" might be null.

        if (client && client->session()) {



 Comments   
Comment by Githook User [ 12/Mar/19 ]

Author:

{'name': 'Jason Carey', 'username': 'hanumantmk', 'email': 'jcarey@argv.me'}

Message: SERVER-39303 Fix several useless Client* checks

The checks performed in functions that are never passed a nullptr and
would crash later if null was ever passed. Removing the checks makes
coverity happy.

(cherry picked from commit e61f7582788f51b2287f179c8f27ec8fa41744f7)
Branch: v4.0
https://github.com/mongodb/mongo/commit/091b3c02c03d59db32809ade8264e163adc12cd2

Comment by Githook User [ 26/Feb/19 ]

Author:

{'name': 'Jason Carey', 'username': 'hanumantmk', 'email': 'jcarey@argv.me'}

Message: SERVER-39303 Fix several useless Client* checks

The checks performed in functions that are never passed a nullptr and
would crash later if null was ever passed. Removing the checks makes
coverity happy.
Branch: master
https://github.com/mongodb/mongo/commit/e61f7582788f51b2287f179c8f27ec8fa41744f7

Generated at Thu Feb 08 04:51:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.