[SERVER-55003] Coverity analysis defect 117786: Dereference after null check Created: 05/Mar/21  Updated: 27/Oct/23  Resolved: 24/Mar/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Henrik Edin
Resolution: Works as Designed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Sprint: Execution Team 2021-04-05
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/catalog/create_collection.cpp:525: FORWARD_NULL 117786 Comparing "db" to null implies that "db" might be null.
/src/mongo/db/catalog/create_collection.cpp:532: FORWARD_NULL 117786 Passing null pointer "db" to "makeUniqueCollectionNamespace", which dereferences it. (The dereference happens because this is a virtual function call.)



 Comments   
Comment by Henrik Edin [ 24/Mar/21 ]

Coverity seem to be confused by the code. Dereferencing of db when calling makeUniqueCollectionNamespace is protected by the needsRenaming which is derived from db

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