[SERVER-75021] Coverity analysis defect 135525: Dereference null return value Created: 19/Mar/23  Updated: 29/Oct/23  Resolved: 29/Mar/23

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

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

Issue Links:
Problem/Incident
is caused by SERVER-74667 Use lock-free read approch for checkM... Closed
Assigned Teams:
Sharding EMEA
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding EMEA 2023-04-03
Participants:

 Description   

Dereference null return value

If the function actually returns a null value, a null pointer dereference will occur. Return value of function which returns null is dereferenced without checking
/src/mongo/db/s/shardsvr_check_metadata_consistency_participant_command.cpp:100: NULL_RETURNS 135525 Dereferencing a pointer that might be "nullptr" "*it" when calling "ns". (The dereference happens because this is a virtual function call.)



 Comments   
Comment by Githook User [ 29/Mar/23 ]

Author:

{'name': 'Antonio Fuschetto', 'email': 'antonio.fuschetto@mongodb.com', 'username': 'afuschetto'}

Message: SERVER-75021 Coverity analysis defect 135525: Dereference null return value
Branch: master
https://github.com/mongodb/mongo/commit/cd6a60a933265227d24381543e8de79a3220e757

Comment by Antonio Fuschetto [ 29/Mar/23 ]

The defect raised by Coverity is based on the fact that the CollectionCatalog iterator could refer to nullptr when the end of the catalog is reached or the database doesn't match. It is therefore a case that should never occur in an usual iteration from the first to the last element.

I noticed that in other cases there it has been implemented a check (e.g., here and here) to keep Coverity happy.

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