[CDRIVER-918] Coverity analysis defect 76371: Dereference null return value Created: 08/Oct/15  Updated: 21/Apr/17  Resolved: 14/Oct/15

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.3.0-beta0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Return value of function which returns null is dereferenced without checking

Defect 76371 (STATIC_C)
Checker NULL_RETURNS (subcategory none)
File: /src/mongoc/mongoc-collection.c
Function mongoc_collection_create_index
/src/mongoc/mongoc-collection.c, line: 821
Assigning: "alloc_name" = null return value from "mongoc_collection_keys_to_index_string".

          alloc_name = mongoc_collection_keys_to_index_string (keys);

/src/mongoc/mongoc-collection.c, line: 822
Assigning: "name" = "alloc_name". Both pointers are now null.

          name = alloc_name;

/src/mongoc/mongoc-collection.c, line: 832
Dereferencing a pointer that might be null "name" when calling "strlen".

       BSON_APPEND_UTF8 (&doc, "name", name);



 Comments   
Comment by Githook User [ 14/Oct/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-918: Dereference null return value
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/fb7a01742c53456a43bffe5193f17c057bfdc961

Generated at Wed Feb 07 21:11:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.