Resolves: tdf#153116 null-ptr-deref in get-surrounding-text
#0 SwFrame::IsTextFrame() const (this=0x0) at sw/source/core/inc/frame.hxx:1236
#1 0x00007fffa8dcb865 in sw::FrameContainsNode(SwContentFrame const&, o3tl::strong_int<int, Tag_SwNodeOffset>) (rFrame=..., nNodeIndex=...) at sw/source/core/text/txtfrm.cxx:292
#2 0x00007fffa82c9fd4 in SwCursorShell::GetSelText() const (this=0x5509470) at sw/source/core/crsr/crsrsh.cxx:2565
#3 0x00007fffa89017f0 in SwEditShell::GetSelectedText(rtl::OUString&, ParaBreakType) (this=0x5509470, rBuf="", nHndlParaBrk=ParaBreakType::ToOnlyCR)
at sw/source/core/edit/edglss.cxx:264
#4 0x00007fffa97e19a7 in SwEditWin::GetSurroundingText() const (this=0x4f1a9f0) at sw/source/uibase/docvw/edtwin.cxx:6628
#5 0x00007fffee27cf02 in ImplHandleSurroundingTextRequest(vcl::Window*, rtl::OUString&, Selection&) (pWindow=0x1fe43f0, rText="", rSelRange=...) at vcl/source/window/winproc.cxx:2544
#6 0x00007fffee27adf7 in ImplHandleSalSurroundingTextRequest(vcl::Window*, SalSurroundingTextRequestEvent*) (pWindow=0x1fe43f0, pEvt=0x7fffffffb970)
at vcl/source/window/winproc.cxx:2555
#7 0x00007fffee276ed6 in ImplWindowFrameProc(vcl::Window*, SalEvent, void const*) (_pWindow=0x1fe43f0, nEvent=SalEvent::SurroundingTextRequest, pEvent=0x7fffffffb970)
at vcl/source/window/winproc.cxx:2884
#8 0x00007fffe6ee3080 in SalFrame::CallCallback(SalEvent, void const*) const (this=0x1898310, nEvent=SalEvent::SurroundingTextRequest, pEvent=0x7fffffffb970) at vcl/inc/salframe.hxx:306
Change-Id: I7330865b5dda7766a6da08f57a7dd8dd1a09d198
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146016
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 725c7ed..b270cdb 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2562,7 +2562,7 @@ OUString SwCursorShell::GetSelText() const
if (GetLayout()->HasMergedParas())
{
SwContentFrame const*const pFrame(GetCurrFrame(false));
if (FrameContainsNode(*pFrame, m_pCurrentCursor->GetMark()->GetNodeIndex()))
if (pFrame && FrameContainsNode(*pFrame, m_pCurrentCursor->GetMark()->GetNodeIndex()))
{
OUStringBuffer buf;
SwPosition const*const pStart(m_pCurrentCursor->Start());