sw/source/core/unocore/unoobj2.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
New commits: commit 16a94d2b25198442af1257574bf88007c8b352f3 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Jul 4 15:53:39 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jul 4 23:05:45 2023 +0200 sw: fix crash in CreateParentXText See https://crashreport.libreoffice.org/stats/signature/SfxObjectShell::GetBaseModel() Change-Id: Idcfc8219b5765bca9c45819bde5f276ce68c45de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153971 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 210e62655a15..1b02cb5a0b27 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1307,12 +1307,14 @@ CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) break; default: { - // then it is the body text - const uno::Reference<frame::XModel> xModel = - rDoc.GetDocShell()->GetBaseModel(); - const uno::Reference< text::XTextDocument > xDoc( - xModel, uno::UNO_QUERY); - xParentText = xDoc->getText(); + if (SwDocShell *const pDocSh = rDoc.GetDocShell()) + { + // then it is the body text + const uno::Reference<frame::XModel> xModel = pDocSh->GetBaseModel(); + const uno::Reference< text::XTextDocument > xDoc( + xModel, uno::UNO_QUERY); + xParentText = xDoc->getText(); + } } } OSL_ENSURE(xParentText.is(), "no parent text?");