[CDRIVER-2252] Coverity analysis defect 101971: Resource leak Created: 24/Aug/17  Updated: 28/Oct/23  Resolved: 29/Aug/17

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.8.0

Type: Bug Priority: Minor - P4
Reporter: Coverity Collector User Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Leak of memory or pointers to system resources

Defect 101971 (STATIC_C)
Checker RESOURCE_LEAK (subcategory none)
File: /src/mongoc/mongoc-client.c
Function mongoc_client_kill_cursor
/src/mongoc/mongoc-client.c, line: 1840
Assigning: "read_prefs" = storage returned from "mongoc_read_prefs_new(MONGOC_READ_PRIMARY)".

       read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY);

/src/mongoc/mongoc-client.c, line: 1846
Variable "read_prefs" going out of scope leaks the storage it points to.

          return;



 Comments   
Comment by Githook User [ 29/Aug/17 ]

Author:

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

Message: Merge branch 'master' of github.com:mongodb/mongo-c-driver

Comment by Githook User [ 29/Aug/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2252 leak in mongoc_client_kill_cursors

Very minor leak: the topology must include incompatible servers, so no
operations will succeed in any case, and the application must call the
deprecated and useless mongoc_client_kill_cursors function repeatedly.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/f18c8660d5fd4d551d0ecd51a4167388e74f748e

Comment by A. Jesse Jiryu Davis [ 29/Aug/17 ]

This is very rare and low-impact: the topology would have to be "incompatible" (containing servers too old or too new for this C Driver version) and an application would have to repeatedly call the deprecated and useless mongoc_client_kill_cursor, leaking one mongoc_read_prefs_t struct per call.

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