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

Memory leak in BSONIteratorSorted

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.0.6, 2.1.1
    • Fix Version/s: 3.1.0
    • Component/s: Internal Client
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Platform 0 3/13/15

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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: