[Libreoffice] question about memory leak detected by cppcheck

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


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

     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...
(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 ?


(i just updated cppcheck with git and recompiled it)

More information about the LibreOffice mailing list