[SERVER-6168] Memory leak in BSONIteratorSorted Created: 21/Jun/12  Updated: 19/Sep/15  Resolved: 03/Mar/15

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: 2.0.6, 2.1.1
Fix Version/s: 3.1.0

Type: Bug Priority: Major - P3
Reporter: Andy Schwerin Assignee: Tyler Brock
Resolution: Done Votes: 0
Labels: cxxcopy
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Platform 0 3/13/15
Participants:

 Description   

In the following constructor for BSONIteratorSorted, if any of the verify() checks fail, a MsgAssertionException will be thrown, The result is that the destructor for BSONIteratorSorted will not be run, and the memory pointed to by _fields will not be freed.

 
    BSONIteratorSorted::BSONIteratorSorted( const BSONObj &o, const ElementFieldCmp &cmp ) {
        _nfields = o.nFields();
        _fields = new const char*[_nfields];
        int x = 0;
        BSONObjIterator i( o );
        while ( i.more() ) {
            _fields[x++] = i.next().rawdata();
            verify( _fields[x-1] );
        }
        verify( x == _nfields );
        std::sort( _fields , _fields + _nfields , cmp );
        _cur = 0;
    }



 Comments   
Comment by Githook User [ 03/Mar/15 ]

Author:

{u'username': u'TylerBrock', u'name': u'Tyler Brock', u'email': u'tyler.brock@gmail.com'}

Message: SERVER-6168 Fix exception memory leak in BSONIteratorSorted
Branch: master
https://github.com/mongodb/mongo/commit/69fbf40bdc14d2a0237749a3ad607cfe0f83bc8b

Generated at Thu Feb 08 03:10:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.