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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sun Aug 22 11:50:58 UTC 2021


 sw/source/core/doc/DocumentContentOperationsManager.cxx |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

New commits:
commit eb05182c68f4c6c842da216c9662fce7a6d0047d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Aug 21 17:27:28 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Aug 22 13:50:23 2021 +0200

    cid#1490402 Resource leak
    
    Change-Id: I345fa61dddf25cadc79fae7d2edd706fd2b45eb4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120823
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index e587ffd27770..6fcca55fbbe0 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1215,7 +1215,7 @@ namespace //local functions originally from docfmt.cxx
         SwDoc& rDoc,
         const SwPaM &rRg)
     {
-        SwRedlineExtraData_FormatColl* pExtra = nullptr;
+        std::unique_ptr<SwRedlineExtraData_FormatColl> xExtra;
 
         // check existing redline on the same range, and use its extra data, if it exists
         SwRedlineTable::size_type nRedlPos = rDoc.getIDocumentRedlineAccess().GetRedlinePos(
@@ -1240,7 +1240,7 @@ namespace //local functions originally from docfmt.cxx
                         {
                             // Get the item set that holds all the changes properties
                             const SfxItemSet *pChangesSet = pFormattingChanges->GetItemSet();
-                            pExtra = new SwRedlineExtraData_FormatColl( "", USHRT_MAX, pChangesSet );
+                            xExtra.reset(new SwRedlineExtraData_FormatColl("", USHRT_MAX, pChangesSet));
                             break;
                         }
                     }
@@ -1254,7 +1254,7 @@ namespace //local functions originally from docfmt.cxx
         if (IDocumentRedlineAccess::AppendResult::IGNORED != result)
         {
             // no existing format redline in the range
-            if (!pExtra)
+            if (!xExtra)
             {
                 // Apply the first character's attributes to the ReplaceText
                 SfxItemSet aSet( rDoc.GetAttrPool(),
@@ -1269,14 +1269,12 @@ namespace //local functions originally from docfmt.cxx
                 aSet.ClearItem( RES_TXTATR_INETFMT );
                 aSet.ClearItem( RES_TXTATR_META );
                 aSet.ClearItem( RES_TXTATR_METAFIELD );
-                pExtra = new SwRedlineExtraData_FormatColl( "", USHRT_MAX, &aSet );
+                xExtra.reset(new SwRedlineExtraData_FormatColl("", USHRT_MAX, &aSet));
             }
 
-            if ( pExtra )
+            if (xExtra)
             {
-                std::unique_ptr<SwRedlineExtraData_FormatColl> xRedlineExtraData;
-                xRedlineExtraData.reset(pExtra);
-                pRedline->SetExtraData( xRedlineExtraData.get() );
+                pRedline->SetExtraData(xExtra.get() );
             }
         }
     }


More information about the Libreoffice-commits mailing list