sw/source/core/unocore/unoobj2.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
New commits: commit 98a3a5dc591e4317655895d2fd91b87890144332 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Jul 4 15:53:39 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Jul 5 11:24:54 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> (cherry picked from commit a0669a1a4963b2611fb372c8394ea4530d2c9e96) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154003 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index e5fefbc0e376..f1c5a7e3675a 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1319,12 +1319,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?");