[CDRIVER-2136] Coverity analysis defect 72309: Resource leak Created: 21/Apr/17  Updated: 28/Oct/23  Resolved: 05/Jun/17

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

Type: Bug Priority: Major - P3
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 72309 (STATIC_C)
Checker RESOURCE_LEAK (subcategory none)
File: /src/tools/mongoc-stat.c
Function mongoc_counters_new_from_pid
/src/tools/mongoc-stat.c, line: 104
Storage is returned from allocation function "mmap".

       if (MAP_FAILED == (mem = mmap (NULL, size, PROT_READ, MAP_SHARED, fd, 0))) {

/src/tools/mongoc-stat.c, line: 104
Assigning: "mem" = storage returned from "mmap(NULL, size, 1, 1, fd, 0L)".

       if (MAP_FAILED == (mem = mmap (NULL, size, PROT_READ, MAP_SHARED, fd, 0))) {

/src/tools/mongoc-stat.c, line: 112
Assigning: "counters" = "mem".

       counters = (mongoc_counters_t *) mem;

/src/tools/mongoc-stat.c, line: 115
Variable "mem" going out of scope leaks the storage it points to.

          return NULL;

/src/tools/mongoc-stat.c, line: 115
Variable "counters" going out of scope leaks the storage it points to.

          return NULL;



 Comments   
Comment by Githook User [ 09/May/17 ]

Author:

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

Message: CDRIVER-2136 compiler warning in mongoc-stat
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/094225bb03e3ad6a7c486c06159ed68eeceedf5d

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