[SERVER-77384] Coverity analysis defect 138136: Dereference after null check Created: 22/May/23  Updated: 29/Oct/23  Resolved: 10/Aug/23

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Improvement Priority: Minor - P4
Reporter: Coverity Collector User Assignee: Maya Srikanth (Inactive)
Resolution: Fixed Votes: 0
Labels: coverity, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Participants:

 Description   

Dereference after null check

Either the check against null is unnecessary, or there may be a null pointer dereference. Pointer is checked against null but then dereferenced anyway
/src/mongo/db/pipeline/expression_context.cpp:136: FORWARD_NULL 138136 Comparing "opCtx" to null implies that "opCtx" might be null.



 Comments   
Comment by Githook User [ 10/Aug/23 ]

Author:

{'name': 'Maya Srikanth', 'email': 'maya.srikanth@mongodb.com', 'username': ''}

Message: SERVER-77384 added assertion for Operation Context
Branch: master
https://github.com/mongodb/mongo/commit/5a45147a3c8d91777f4d34516b7fe783d6508b51

Comment by Kyle Suarez [ 23/May/23 ]

I'm marking this as an "Improvement" and not a "Bug" because IIRC, the OperationContext should actually be set here and not null. If that is truly the case we should just assert as such and then not treat like the opCtx could be nullish. (I felt like I had a conversation about this with someone recently, but I cannot remember.)

Generated at Thu Feb 08 06:35:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.