[Libreoffice-commits] core.git: sw/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jul 20 18:00:04 UTC 2017


 sw/source/core/doc/docfld.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 4a128f336a146a12c28bb9f3bdfa24d2198d85dc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Jul 20 17:10:50 2017 +0200

    tdf#109197 crash when deleting user field variables in sw
    
    regression from:
    commit a706bb06d5326e7a997dd1d71f3f947bd0ad28e6
    "new loplugin: useuniqueptr: sw part 1"
    
    Change-Id: I57f9c9e6d7eeccc033b71d7182c960f3d79df73c
    Reviewed-on: https://gerrit.libreoffice.org/40240
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 00eb8b0466f6..d27d6c9fce19 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -1135,15 +1135,18 @@ void SwDocUpdateField::RemoveFieldType( const SwFieldType& rType )
         if( pFnd )
         {
             if( aFieldTypeTable[ n ] == pFnd )
+            {
                 aFieldTypeTable[ n ] = static_cast<SwCalcFieldType*>(pFnd->pNext.release());
+                delete pFnd;
+            }
             else
             {
                 SwHash* pPrev = aFieldTypeTable[ n ];
                 while( pPrev->pNext.get() != pFnd )
                     pPrev = pPrev->pNext.get();
                 pPrev->pNext = std::move(pFnd->pNext);
+                // no need to explicitly delete here, the embedded linked list uses unique_ptr
             }
-            delete pFnd;
         }
     }
 }


More information about the Libreoffice-commits mailing list