[Libreoffice] question about memory leak detected by cppcheck

Julien Nabet serval2412 at yahoo.fr
Fri Nov 19 23:37:24 PST 2010


Hello,

In the file filters/binfilter/bf_svtools/source/items/svt_aeitem.cxx
We've got this :
SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
     SfxEnumItem(rCopy),
     pValues(0),
     pDisabledValues( 0 )
{
     DBG_CTOR(SfxAllEnumItem, 0);
     if ( !rCopy.pValues )
         return;

     pValues = new SfxAllEnumValueArr;

     for ( USHORT nPos = 0; nPos < rCopy.pValues->Count(); ++nPos )
     {
         SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
         pVal->nValue = rCopy.pValues->GetObject(nPos)->nValue;
         pVal->aText = rCopy.pValues->GetObject(nPos)->aText;
         const SfxAllEnumValue_Impl *pTemp = pVal;
         pValues->Insert( pTemp, nPos );
     }

...
And cppcheck says :
Checking ./filters/binfilter/bf_svtools/source/items/svt_aeitem.cxx...
[./filters/binfilter/bf_svtools/source/items/svt_aeitem.cxx:110]: 
(error) Memory leak: pVal

In my opinion it's a false positive since pVal mustn't be destroyed 
since it's indirectly used via pTemp in pValues.
Am i right or wrong ?

Julien.

(i just updated cppcheck with git and recompiled it)


More information about the LibreOffice mailing list