Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-2168

Memory leak in ValueVectorOf

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.0, 3.2.1, 3.2.2
    • 3.2.3
    • Utilities
    • None
    • Patch

    Description

      ValueVectorOf has been changed to call the object destructors for example in ~ValueOfVector:

      template <class TElem> ValueVectorOf<TElem>::~ValueVectorOf()
      {
          if (fCallDestructor) {
              for (XMLSize_t index=fMaxCount; index > 0; index--)
                  fElemList[index-1].~TElem();
          }
          fMemoryManager->deallolink titlecate(fElemList); //delete [] fElemList;
      {color:#205081}}

      But the code is missing in ValueVectorOf<TElem>::operator=.

      A sample code is attached with the corresponding valgrind reports. The sample covers the case where the buffer shrinks (no realloc) or grows (pass realloc as argument to the command).

      The attached patch fixes the leak.

       

       

      Attachments

        1. xerces_leak.cpp
          2 kB
          Laurent Pelecq
        2. xerces_operator_leak.patch
          0.7 kB
          Laurent Pelecq
        3. memory_leaks_realloc.txt
          2 kB
          Laurent Pelecq
        4. memory_leaks_no_realloc.txt
          2 kB
          Laurent Pelecq

        Activity

          People

            scantor Scott Cantor
            lpcq Laurent Pelecq
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: