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
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to