[SERVER-73132] Coverity analysis defect 134901: Dereference null return value Created: 20/Jan/23  Updated: 27/Oct/23  Resolved: 12/Apr/23

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: Gregory Wlodarek
Resolution: Gone away Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Operating System: ALL
Sprint: Execution Team 2023-04-17
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/catalog/collection_catalog.cpp:800: NULL_RETURNS 134901 Assigning: "latestCollection" = "nullptr" return value from "lookupCollectionByNamespaceForRead".
/src/mongo/db/catalog/collection_catalog.cpp:804: NULL_RETURNS 134901 Attempting to access the managed object of an empty smart pointer "latestCollection".



 Comments   
Comment by Gregory Wlodarek [ 12/Apr/23 ]

Fixed in SERVER-74369

Comment by Matt Kneiser [ 11/Apr/23 ]

Offending code from the past:
https://github.com/mongodb/mongo/blob/62949c560f99bd257c54a52ca7bbc96b74e7d27d/src/mongo/db/catalog/collection_catalog.cpp#L800-L804

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