Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


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.

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.