Le 20/11/2010 17:18, Caolán McNamara a écrit :
On Sat, 2010-11-20 at 08:37 +0100, Julien Nabet wrote:

          SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
...
          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
Without looking at the full impl of SfxAllEnumValueArr its hard to tell.
I would imagine that cppcheck can't tell either :-). So, just for the
sake of a cppcheck test change

const SfxAllEnumValue_Impl *pTemp = pVal;
pValues->Insert( pTemp, nPos );

to

pValues->Insert( pVal, nPos );

or

pValues->Insert( (const SfxAllEnumValue_Impl*)pTmp, nPos );

and see if cppcheck still complains, or if the cast has confused it.

C.


With

pValues->Insert( pVal, nPos );

it works

but with :

pValues->Insert( (const SfxAllEnumValue_Impl*)pTmp, nPos );

it doesn't work.

So must i declare a new bug for cppcheck by describing the current and your second proposition that don't work ?

Another question : what is the utility of pTemp ? it's for having a "const" pointer ?

Julien.
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to