sc/source/ui/drawfunc/fuins1.cxx |   39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

New commits:
commit 805bd3bf57f1e88d579def0ac5d2436b38fc8966
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Oct 18 01:56:51 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Jan 7 12:22:27 2025 +0100

    tdf#163486: PVS: check pDrawView
    
    V595    The 'pDrawView' pointer was utilized before it was verified against 
nullptr. Check lines: 128, 133.
    
    Change-Id: Ic07658428e4eb74d42d800df23b198800a9bab09
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175115
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 7d9357eb5d996e4c70bbb4cd534daa9f70f78354)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175059
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index 886d2b29ecf3..83fd3d7227c0 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -125,32 +125,35 @@ static void lcl_InsertGraphic( const Graphic& rGraphic,
         }
     }
     ScDrawView* pDrawView = rViewSh.GetScDrawView();
-    const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
 
     // #i123922# check if an existing object is selected; if yes, evtl. replace
     // the graphic for a SdrGraphObj (including link state updates) or adapt 
the fill
     // style for other objects
-    if(pDrawView && 1 == rMarkList.GetMarkCount())
+    if(pDrawView)
     {
-        SdrObject* pPickObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
-
-        if(pPickObj)
+        const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
+        if (1 == rMarkList.GetMarkCount())
         {
-            //sal_Int8 nAction(DND_ACTION_MOVE);
-            //Point aPos;
-            const OUString aBeginUndo(ScResId(STR_UNDO_DRAGDROP));
-
-            SdrObject* pResult = pDrawView->ApplyGraphicToObject(
-                *pPickObj,
-                rGraphic1,
-                aBeginUndo,
-                bAsLink ? rFileName : OUString());
+            SdrObject* pPickObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
 
-            if(pResult)
+            if(pPickObj)
             {
-                // we are done; mark the modified/new object
-                pDrawView->MarkObj(pResult, pDrawView->GetSdrPageView());
-                return;
+                //sal_Int8 nAction(DND_ACTION_MOVE);
+                //Point aPos;
+                const OUString aBeginUndo(ScResId(STR_UNDO_DRAGDROP));
+
+                SdrObject* pResult = pDrawView->ApplyGraphicToObject(
+                    *pPickObj,
+                    rGraphic1,
+                    aBeginUndo,
+                    bAsLink ? rFileName : OUString());
+
+                if(pResult)
+                {
+                    // we are done; mark the modified/new object
+                    pDrawView->MarkObj(pResult, pDrawView->GetSdrPageView());
+                    return;
+                }
             }
         }
     }

Reply via email to