[Libreoffice-commits] core.git: sc/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Dec 23 18:48:51 UTC 2020
sc/source/filter/lotus/lotfilter.hxx | 5 +++--
sc/source/filter/lotus/lotus.cxx | 12 +++++-------
sc/source/filter/lotus/memory.cxx | 25 +++++++++++++------------
sc/source/filter/lotus/tool.cxx | 12 ++++++------
4 files changed, 27 insertions(+), 27 deletions(-)
New commits:
commit 473ca9b7530df1e7d24e2fc36b88619b73029ac8
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Dec 23 17:14:11 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Dec 23 19:48:08 2020 +0100
ofz#28910 Direct-leak in MemNew
Change-Id: I108e8dae8fa32feef0a56412dcaeb92e9d714975
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108240
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/source/filter/lotus/lotfilter.hxx b/sc/source/filter/lotus/lotfilter.hxx
index 043e950525ce..5a074cab7df7 100644
--- a/sc/source/filter/lotus/lotfilter.hxx
+++ b/sc/source/filter/lotus/lotfilter.hxx
@@ -45,9 +45,9 @@ struct LotusContext
ScDocument& rDoc; // reference to access document
std::map<sal_uInt16, ScPatternAttr> aLotusPatternPool;
- SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter, *pAttrRepeat, *pAttrStandard;
+ std::unique_ptr<SvxHorJustifyItem> xAttrRight, xAttrLeft, xAttrCenter, xAttrRepeat, xAttrStandard;
- FormCache* pValueFormCache; // -> initialized in memory.cxx
+ std::unique_ptr<FormCache> xValueFormCache; // -> initialized in memory.cxx
LotusRangeList maRangeNames;
Lotus123Typ eFirstType;
@@ -58,6 +58,7 @@ struct LotusContext
LotAttrTable maAttrTable;
LotusContext(ScDocument& rDocP, rtl_TextEncoding eQ);
+ ~LotusContext();
};
#endif
diff --git a/sc/source/filter/lotus/lotus.cxx b/sc/source/filter/lotus/lotus.cxx
index 291471e1b880..7d7dc17f88a3 100644
--- a/sc/source/filter/lotus/lotus.cxx
+++ b/sc/source/filter/lotus/lotus.cxx
@@ -20,12 +20,13 @@
#include "lotfilter.hxx"
#include <lotimpop.hxx>
+#include <editeng/justifyitem.hxx>
#include <sfx2/docfile.hxx>
#include <tools/urlobj.hxx>
-
#include <scerrors.hxx>
#include <filtopt.hxx>
#include <ftools.hxx>
+#include <tool.h>
ErrCode ScFormatFilterPluginImpl::ScImportLotus123( SfxMedium& rMedium, ScDocument& rDocument, rtl_TextEncoding eSrc )
{
@@ -85,12 +86,6 @@ LotusContext::LotusContext(ScDocument& rDocP, rtl_TextEncoding eQ)
, bEOF(false)
, eCharset(eQ)
, rDoc(rDocP)
- , pAttrRight(nullptr)
- , pAttrLeft(nullptr)
- , pAttrCenter(nullptr)
- , pAttrRepeat(nullptr)
- , pAttrStandard(nullptr)
- , pValueFormCache(nullptr)
, maRangeNames()
, eFirstType( Lotus123Typ::X)
, eActType( Lotus123Typ::X)
@@ -99,5 +94,8 @@ LotusContext::LotusContext(ScDocument& rDocP, rtl_TextEncoding eQ)
{
}
+LotusContext::~LotusContext()
+{
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/lotus/memory.cxx b/sc/source/filter/lotus/memory.cxx
index a5543daa8229..97ba1654cc3d 100644
--- a/sc/source/filter/lotus/memory.cxx
+++ b/sc/source/filter/lotus/memory.cxx
@@ -29,26 +29,27 @@
bool MemNew(LotusContext& rContext)
{
- rContext.pValueFormCache = new FormCache(&rContext.rDoc);
+ rContext.xValueFormCache.reset(new FormCache(&rContext.rDoc));
// for tool.cxx::PutFormString()
- rContext.pAttrRight = new SvxHorJustifyItem(SvxCellHorJustify::Right, ATTR_HOR_JUSTIFY);
- rContext.pAttrLeft = new SvxHorJustifyItem(SvxCellHorJustify::Left, ATTR_HOR_JUSTIFY);
- rContext.pAttrCenter = new SvxHorJustifyItem(SvxCellHorJustify::Center, ATTR_HOR_JUSTIFY);
- rContext.pAttrRepeat = new SvxHorJustifyItem(SvxCellHorJustify::Repeat, ATTR_HOR_JUSTIFY);
- rContext.pAttrStandard = new SvxHorJustifyItem(SvxCellHorJustify::Standard, ATTR_HOR_JUSTIFY);
+ rContext.xAttrRight.reset(new SvxHorJustifyItem(SvxCellHorJustify::Right, ATTR_HOR_JUSTIFY));
+ rContext.xAttrLeft.reset(new SvxHorJustifyItem(SvxCellHorJustify::Left, ATTR_HOR_JUSTIFY));
+ rContext.xAttrCenter.reset(new SvxHorJustifyItem(SvxCellHorJustify::Center, ATTR_HOR_JUSTIFY));
+ rContext.xAttrRepeat.reset(new SvxHorJustifyItem(SvxCellHorJustify::Repeat, ATTR_HOR_JUSTIFY));
+ rContext.xAttrStandard.reset(
+ new SvxHorJustifyItem(SvxCellHorJustify::Standard, ATTR_HOR_JUSTIFY));
return true;
}
void MemDelete(LotusContext& rContext)
{
- delete rContext.pValueFormCache;
- delete rContext.pAttrRight;
- delete rContext.pAttrLeft;
- delete rContext.pAttrCenter;
- delete rContext.pAttrRepeat;
- delete rContext.pAttrStandard;
+ rContext.xValueFormCache.reset();
+ rContext.xAttrRight.reset();
+ rContext.xAttrLeft.reset();
+ rContext.xAttrCenter.reset();
+ rContext.xAttrRepeat.reset();
+ rContext.xAttrStandard.reset();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index fb711db71c5b..c57e37f422b0 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -49,26 +49,26 @@ void PutFormString(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, c
switch( cForm )
{
case '"': // align-right
- pJustify = rContext.pAttrRight;
+ pJustify = rContext.xAttrRight.get();
pString++;
break;
case '\'': // align-left
- pJustify = rContext.pAttrLeft;
+ pJustify = rContext.xAttrLeft.get();
pString++;
break;
case '^': // centered
- pJustify = rContext.pAttrCenter;
+ pJustify = rContext.xAttrCenter.get();
pString++;
break;
case '|': // printer command
pString = nullptr;
break;
case '\\': // repetition
- pJustify = rContext.pAttrRepeat;
+ pJustify = rContext.xAttrRepeat.get();
pString++;
break;
default: // undefined case!
- pJustify = rContext.pAttrStandard;
+ pJustify = rContext.xAttrStandard.get();
}
if (!pString)
@@ -91,7 +91,7 @@ void SetFormat(LotusContext& rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_u
nTab = SanitizeTab(nTab);
// PREC: nSt = default number of decimal places
- rContext.rDoc.ApplyAttr(nCol, nRow, nTab, *(rContext.pValueFormCache->GetAttr(nFormat, nSt)));
+ rContext.rDoc.ApplyAttr(nCol, nRow, nTab, *(rContext.xValueFormCache->GetAttr(nFormat, nSt)));
ScProtectionAttr aAttr;
More information about the Libreoffice-commits
mailing list