You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Boris Kolpackov (JIRA)" <xe...@xml.apache.org> on 2009/11/17 14:30:39 UTC

[jira] Closed: (XERCESC-1455) Template ValueVectorOf does not call destructors for removing objects. A memory leak could result from this.

     [ https://issues.apache.org/jira/browse/XERCESC-1455?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Boris Kolpackov closed XERCESC-1455.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 3.0.1

I see that there is now the callDestructor flag in ValueVectorOf. So I assume this has been fixed (in an ugly way).

> Template ValueVectorOf does not call destructors for removing objects. A memory leak could result from this.
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: XERCESC-1455
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1455
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.3.0
>         Environment: Solaris
>            Reporter: Alex Akula
>            Assignee: David Bertoni
>             Fix For: 3.0.1
>
>         Attachments: patch.txt
>
>
> When objects get removed from ValueVectorOf < object type> container no destructors are called for the objects. Amemory leak could result from this.
> This could be fixed by changing the code:
> template <class TElem> void ValueVectorOf<TElem>::
> removeElementAt(const unsigned int removeAt)
> {
>     if (removeAt >= fCurCount)
>         ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex);
> 	fElemList[removeAt] = 0; // akula --  this is the fix for classes in which assign operator is overloaded appropriate way.
>     if (removeAt == fCurCount-1)
>     {
>         fCurCount--;
>         return;
>     }
>     // Copy down every element above remove point
>     for (unsigned int index = removeAt; index < fCurCount-1; index++)
>         fElemList[index] = fElemList[index+1];
>     // And bump down count
>     fCurCount--;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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