[Libreoffice-commits] core.git: 2 commits - editeng/source tools/source

Stephan Bergmann sbergman at redhat.com
Thu Jan 7 02:14:47 PST 2016


 editeng/source/editeng/editdoc.cxx |   12 +-----------
 editeng/source/editeng/editdoc.hxx |    1 -
 tools/source/zcodec/zcodec.cxx     |   13 ++++++++-----
 3 files changed, 9 insertions(+), 17 deletions(-)

New commits:
commit 0f6f21346ec989dc31130e6bdc196a2293fcbb2e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jan 7 10:59:19 2016 +0100

    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
    b35980d9b28f1e3985f94238f7d8c9962f654bd0 "Move away from SV_DECL_PTRARR in
    CharAttribList" but then got "fixed" again with
    46da0b6837bffa7d8a72624d2587159737e3d7e2 "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
    "dd127fae0c5661e6488785ed0ecb410d81165a6e prefer:
    e4e4b3d65788d14d5f10cd6bccc713cfe2411cb1," i.e., "Another SV_DECL_PTRARR now
    gone" about some unrelated XBaseParaPortionList).
    
    Change-Id: Iecee5a4c85bc0c0c36a6690d70f0a4a59dab964a

diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 9b484a3..09f5f1f 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -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;
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 5c419cd..ebdfb09 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -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);
commit 85aa507f737b99501bb91cf79985af78f46ff0be
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 6 17:49:49 2016 +0100

    Avoid memory leaks upon (de)compression failure
    
    This e.g. reduces the LSan-reported leakage during CppunitTest_sd_filters_test
    from
    
      SUMMARY: AddressSanitizer: 504104 byte(s) leaked in 4654 allocation(s).
    
    to
    
      SUMMARY: AddressSanitizer: 115048 byte(s) leaked in 4639 allocation(s).
    
    Change-Id: If922e872d9f696847face198e082144ccd5f12de

diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 7a983aaf..f11f789 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -82,17 +82,20 @@ long ZCodec::EndCompression()
 {
     long retvalue = 0;
 
-    if (mbStatus && meState != STATE_INIT)
+    if (meState != STATE_INIT)
     {
         if (meState == STATE_COMPRESS)
         {
-            do
+            if (mbStatus)
             {
+                do
+                {
+                    ImplWriteBack();
+                }
+                while ( deflate( PZSTREAM, Z_FINISH ) != Z_STREAM_END );
+
                 ImplWriteBack();
             }
-            while ( deflate( PZSTREAM, Z_FINISH ) != Z_STREAM_END );
-
-            ImplWriteBack();
 
             retvalue = PZSTREAM->total_in;
             deflateEnd( PZSTREAM );


More information about the Libreoffice-commits mailing list