Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6168

Memory leak in BSONIteratorSorted

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.0
    • Affects Version/s: 2.0.6, 2.1.1
    • Component/s: Internal Client
    • Labels:
    • 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;
          }
      

            Assignee:
            tyler@10gen.com Tyler Brock
            Reporter:
            schwerin@mongodb.com Andy Schwerin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: