Kaydet (Commit) 0f6f2134 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Fix memory leak

This e.g. reduces the LSan-reported leakage during CppunitTest_sd_filters_test
from

  SUMMARY: AddressSanitizer: 115048 byte(s) leaked in 4639 allocation(s).

to

  SUMMARY: AddressSanitizer: 6544 byte(s) leaked in 118 allocation(s).

The history is that this happened to (presumably accidentally) get fixed when
switching from an SV_DECL_PTRARR to a boost::ptr_vector in
b35980d9 "Move away from SV_DECL_PTRARR in
CharAttribList" but then got "fixed" again with
46da0b68 "further sc/editeng unbreaking."  That
latter commit doesn't give any more detail than "this boost::ptr_vector idea is
seriously broken," but I assume it did that change only via code inspection, to
return to the previous (assumed good) status quo, rather than because that
recently introduced deletion actually caused any problems there.

I now see that this has also independently been found and fixed in AOO with
<https://bz.apache.org/ooo/show_bug.cgi?id=120865> "Part of EditAttrib objects
are not released after removing from Character attributes list" (the fix for
which apparently got mis-classified for LO as
"dd127fae prefer:
e4e4b3d6," i.e., "Another SV_DECL_PTRARR now
gone" about some unrelated XBaseParaPortionList).

Change-Id: Iecee5a4c85bc0c0c36a6690d70f0a4a59dab964a
üst 85aa507f
......@@ -2590,7 +2590,7 @@ void EditDoc::InsertAttrib( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd
if ( pAttr )
{
// Remove attribute....
rAttrList.Release(pAttr);
rAttrList.Remove(pAttr);
}
// check whether 'the same' attribute exist at this place.
......@@ -2918,16 +2918,6 @@ void CharAttribList::Remove(sal_Int32 nPos)
aAttribs.erase(aAttribs.begin()+nPos);
}
void CharAttribList::Release(const EditCharAttrib* p)
{
AttribsType::iterator it = std::find_if(aAttribs.begin(), aAttribs.end(), FindByAddress(p));
if (it != aAttribs.end())
{
it->release();
aAttribs.erase(it);
}
}
void CharAttribList::SetHasEmptyAttribs(bool b)
{
bHasEmptyAttribs = b;
......
......@@ -225,7 +225,6 @@ public:
void Remove(const EditCharAttrib* p);
void Remove(sal_Int32 nPos);
void Release(const EditCharAttrib* p);
#if OSL_DEBUG_LEVEL > 0
static void DbgCheckAttribs(CharAttribList const& rAttribs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment