[Libreoffice-commits] core.git: sd/source svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 15 20:23:20 UTC 2018


 sd/source/filter/ppt/pptin.cxx                        |    8 +++
 svx/source/customshapes/EnhancedCustomShapeEngine.cxx |   41 ++++++++----------
 2 files changed, 27 insertions(+), 22 deletions(-)

New commits:
commit 307f561e8dce3c7a685de4af92563c9094925de6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Aug 15 11:37:54 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Aug 15 22:22:57 2018 +0200

    ofz#9821 Indirect-leak
    
    Change-Id: I7b4f1a487c49048b7796dba982c5c1d2163cce46
    Reviewed-on: https://gerrit.libreoffice.org/59068
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index c0f022282699..70a5ae3ee8ed 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -2785,7 +2785,13 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportPPT(SvStream &rStream)
         ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false, DocumentType::Impress);
         SdDrawDocument *pDoc = xDocShRef->GetDoc();
 
-        bRet = ImportPPT(pDoc, *xDocStream, *xStorage, aSrcMed);
+        try
+        {
+            bRet = ImportPPT(pDoc, *xDocStream, *xStorage, aSrcMed);
+        }
+        catch (...)
+        {
+        }
 
         xDocShRef->DoClose();
     }
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index de998eb422e5..6a8dd7d3986e 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -298,29 +298,27 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
     bool bFlipH = aCustomShape2d.IsFlipHorz();
     bool bLineGeometryNeededOnly = bTextPathOn;
 
-    SdrObject* pRenderedShape = aCustomShape2d.CreateObject( bLineGeometryNeededOnly );
-    if ( pRenderedShape )
+    std::unique_ptr<SdrObject, SdrObjectFreeOp> xRenderedShape(aCustomShape2d.CreateObject(bLineGeometryNeededOnly));
+    if (xRenderedShape)
     {
         if ( bTextPathOn )
         {
-            SdrObject* pRenderedFontWork(
+            std::unique_ptr<SdrObject, SdrObjectFreeOp> xRenderedFontWork(
                 EnhancedCustomShapeFontWork::CreateFontWork(
-                    pRenderedShape,
+                    xRenderedShape.get(),
                     rSdrObjCustomShape));
 
-            if ( pRenderedFontWork )
+            if (xRenderedFontWork)
             {
-                SdrObject::Free( pRenderedShape );
-                pRenderedShape = pRenderedFontWork;
+                xRenderedShape = std::move(xRenderedFontWork);
             }
         }
-        SdrObject* pRenderedShape3d = EnhancedCustomShape3d::Create3DObject(pRenderedShape, rSdrObjCustomShape);
-        if ( pRenderedShape3d )
+        std::unique_ptr<SdrObject, SdrObjectFreeOp> xRenderedShape3d(EnhancedCustomShape3d::Create3DObject(xRenderedShape.get(), rSdrObjCustomShape));
+        if (xRenderedShape3d)
         {
             bFlipV = bFlipH = false;
             nRotateAngle = 0;
-            SdrObject::Free( pRenderedShape );
-            pRenderedShape = pRenderedShape3d;
+            xRenderedShape = std::move(xRenderedShape3d);
         }
 
         tools::Rectangle aRect(rSdrObjCustomShape.GetSnapRect());
@@ -336,43 +334,44 @@ Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
                 nTan = -nTan;
             }
 
-            pRenderedShape->Shear(rSdrObjCustomShape.GetSnapRect().Center(), nShearAngle, nTan, false);
+            xRenderedShape->Shear(rSdrObjCustomShape.GetSnapRect().Center(), nShearAngle, nTan, false);
         }
         if(nRotateAngle )
         {
             double a = nRotateAngle * F_PI18000;
 
-            pRenderedShape->NbcRotate(rSdrObjCustomShape.GetSnapRect().Center(), nRotateAngle, sin( a ), cos( a ));
+            xRenderedShape->NbcRotate(rSdrObjCustomShape.GetSnapRect().Center(), nRotateAngle, sin( a ), cos( a ));
         }
         if ( bFlipV )
         {
             Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
             Point aRight( aLeft.X() + 1000, aLeft.Y() );
-            pRenderedShape->NbcMirror( aLeft, aRight );
+            xRenderedShape->NbcMirror( aLeft, aRight );
         }
         if ( bFlipH )
         {
             Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
             Point aBottom( aTop.X(), aTop.Y() + 1000 );
-            pRenderedShape->NbcMirror( aTop, aBottom );
+            xRenderedShape->NbcMirror( aTop, aBottom );
         }
 
-        pRenderedShape->NbcSetStyleSheet(rSdrObjCustomShape.GetStyleSheet(), true);
-        pRenderedShape->RecalcSnapRect();
+        xRenderedShape->NbcSetStyleSheet(rSdrObjCustomShape.GetStyleSheet(), true);
+        xRenderedShape->RecalcSnapRect();
     }
 
     if ( mbForceGroupWithText )
     {
-        pRenderedShape = ImplForceGroupWithText(
+        xRenderedShape.reset(ImplForceGroupWithText(
             rSdrObjCustomShape,
-            pRenderedShape);
+            xRenderedShape.release()));
     }
 
     Reference< drawing::XShape > xShape;
 
-    if ( pRenderedShape )
+    if (xRenderedShape)
     {
-        aCustomShape2d.ApplyGluePoints( pRenderedShape );
+        aCustomShape2d.ApplyGluePoints(xRenderedShape.get());
+        SdrObject* pRenderedShape = xRenderedShape.release();
         xShape = SvxDrawPage::CreateShapeByTypeAndInventor( pRenderedShape->GetObjIdentifier(),
             pRenderedShape->GetObjInventor(), pRenderedShape );
     }


More information about the Libreoffice-commits mailing list