|
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;
|
}
|
|