From 416e9ecac90447581825355b772fe722d012b282 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 18 Jul 2019 11:59:49 +0100 Subject: cid#1448217 Use after free MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icb7700c701dd8e9b23bfe29bbedf27ddd9c8f0a1 Reviewed-on: https://gerrit.libreoffice.org/75911 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/source/ui/inc/drawview.hxx | 2 +- sc/source/ui/view/drawview.cxx | 4 ++-- sc/source/ui/view/viewfun7.cxx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx index 5a79b95cc60a..46f5598705f2 100644 --- a/sc/source/ui/inc/drawview.hxx +++ b/sc/source/ui/inc/drawview.hxx @@ -117,7 +117,7 @@ public: bool HasMarkedControl() const; bool HasMarkedInternal() const; - void InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV); + bool InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV); /** Returns the selected object, if it is the caption object of a cell note. @param ppCaptData (out-param) If not null, returns the pointer to the caption object data. */ diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 273431ef0bf5..c2a4dfe58144 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -804,7 +804,7 @@ bool ScDrawView::GetObjectIsMarked( const SdrObject* pObject ) return bisMarked; } -void ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV) +bool ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV) { SdrInsertFlags nOptions=SdrInsertFlags::NONE; // Do not change marks when the ole object is active @@ -817,7 +817,7 @@ void ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV) nOptions |= SdrInsertFlags::DONTMARK; } - InsertObjectAtView( pObj, rPV, nOptions ); + return InsertObjectAtView(pObj, rPV, nOptions); } SdrObject* ScDrawView::GetMarkedNoteCaption( ScDrawObjData** ppCaptData ) diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx index b128516379ff..21ccfc3848a9 100644 --- a/sc/source/ui/view/viewfun7.cxx +++ b/sc/source/ui/view/viewfun7.cxx @@ -447,15 +447,15 @@ bool ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic, pGrafObj->SetName(aName); // don't mark if OLE - pScDrawView->InsertObjectSafe(pGrafObj, *pScDrawView->GetSdrPageView()); + bool bSuccess = pScDrawView->InsertObjectSafe(pGrafObj, *pScDrawView->GetSdrPageView()); // SetGraphicLink has to be used after inserting the object, // otherwise an empty graphic is swapped in and the contact stuff crashes. // See #i37444#. - if (!rFile.isEmpty()) + if (bSuccess && !rFile.isEmpty()) pGrafObj->SetGraphicLink( rFile, ""/*TODO?*/, rFilter ); - return true; + return bSuccess; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit