-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0.6, 2.1.1
-
Component/s: Internal Client
-
Fully Compatible
-
ALL
-
Platform 0 3/13/15
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; }