[Libreoffice-commits] core.git: sc/source
Mike Kaganski
mike.kaganski at collabora.com
Sat Nov 12 11:13:56 UTC 2016
sc/source/core/tool/interpr2.cxx | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
New commits:
commit 737d324c900bc3c89e7d7f955b9b4b6725023679
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Sat Nov 12 13:14:16 2016 +0300
Aviod memory leak in ScInterpreter::ScIntersect()
When one argument is a reference list, and another is a reference,
that reference is converted to temporary list. That list used to
leak because of missing release.
Change-Id: Ic76c9b8769b3a50980cf4d4e3468763b65f21e07
Reviewed-on: https://gerrit.libreoffice.org/30792
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 62627c3..090e492 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2379,22 +2379,25 @@ void ScInterpreter::ScIntersect()
// Convert a reference to list.
const formula::FormulaToken* xt[2] = { x1, x2 };
StackVar sv[2] = { sv1, sv2 };
+ // There may only be one reference; the other is necessarily a list
+ // Ensure converted list proper destruction
+ std::unique_ptr<formula::FormulaToken> p;
for (size_t i=0; i<2; ++i)
{
if (sv[i] == svSingleRef)
{
ScComplexRefData aRef;
aRef.Ref1 = aRef.Ref2 = *xt[i]->GetSingleRef();
- formula::FormulaToken* p = new ScRefListToken;
+ p.reset(new ScRefListToken);
p->GetRefList()->push_back( aRef);
- xt[i] = p;
+ xt[i] = p.get();
}
else if (sv[i] == svDoubleRef)
{
ScComplexRefData aRef = *xt[i]->GetDoubleRef();
- formula::FormulaToken* p = new ScRefListToken;
+ p.reset(new ScRefListToken);
p->GetRefList()->push_back( aRef);
- xt[i] = p;
+ xt[i] = p.get();
}
}
x1 = xt[0];
More information about the Libreoffice-commits
mailing list