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


Hullo List,

In idly reading LO code (trying yet again to spend time wrapping my head around anything in the code base), I'm puzzled by this snippet (with minor format alteration for email) from svl/source/numbers/zforlist.cxx (currently around line 2226). It seems to me that pNewFormat is a memory leak, but I don't know the LO well enough to state that. Specifically, is aFTable.Insert saving the pointed to memory? Or does the SvNumberformat ctor save it somehow? Otherwise, immediately after the if, we reset pNewFormat to a new block of memory, apparently forgetting the old.

This is pattern is replicated a few times in this function, so I'd like to ask before I set about creating a patch.

-----
// Boolean
aFormatCode = pFormatScanner->GetBooleanString();
pNewFormat = new SvNumberformat( aFormatCode,
   pFormatScanner, pStringScanner, nCheckPos, ActLnge );
pNewFormat->SetType(NUMBERFORMAT_LOGICAL);
pNewFormat->SetStandard();
if ( !aFTable.Insert(
   CLOffset + SetIndexTable( NF_BOOLEAN, ZF_STANDARD_LOGICAL ),
   pNewFormat)
   )
    delete pNewFormat;

// Text
aFormatCode = '@';
pNewFormat = new SvNumberformat( aFormatCode,
pFormatScanner, pStringScanner, nCheckPos, ActLnge );
pNewFormat->SetType(NUMBERFORMAT_TEXT);
pNewFormat->SetStandard();
if ( !aFTable.Insert(
   CLOffset + SetIndexTable( NF_TEXT, ZF_STANDARD_TEXT ),
   pNewFormat)
   )
    delete pNewFormat;
-----

Thanks much for any/all advices!

Kevin

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.