[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sw/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jul 20 19:27:27 UTC 2017


 sw/source/core/doc/docfld.cxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 8f232771e84ba0369acb27085813d5810b15724b
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/40244
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index c30341c23394..563c525685f6 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -1138,15 +1138,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.reset( pFnd->pNext.release() );
+                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