Laurent Pelecq created XERCESC-2168:
---------------------------------------

             Summary: Memory leak in ValueVectorOf
                 Key: XERCESC-2168
                 URL: https://issues.apache.org/jira/browse/XERCESC-2168
             Project: Xerces-C++
          Issue Type: Bug
          Components: Utilities
    Affects Versions: 3.2.2
            Reporter: Laurent Pelecq
         Attachments: memory_leaks_no_realloc.txt, memory_leaks_realloc.txt, 
xerces_leak.cpp, xerces_operator_leak.patch

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

{{{color:#205081}template <class TElem> 
ValueVectorOf<TElem>::~ValueVectorOf(){color}}}
{{{color:#205081}{{color}}}
{{    {color:#8eb021}if (fCallDestructor) {{color}}}
{{{color:#8eb021}        for (XMLSize_t index=fMaxCount; index > 0; 
index--){color}}}
{{{color:#8eb021}            fElemList[index-1].~TElem();{color}}}
{{{color:#8eb021}    }{color}}}
{{{color:#205081}    fMemoryManager->deallo[link 
title|http://example.com]cate(fElemList); //delete [] fElemList;{color}}}
{{{color:#205081}}{color}}}

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.

 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org

Reply via email to