From be1addf9eb8e953e4ce4d0c30eca037d580fa7ac Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Sat, 27 Dec 2025 11:33:25 -0900 Subject: [PATCH] related tdf#167491: Prevent SwHistoryBookmark::SetInDoc crash Revealed by sort chapters undo redo of WG7617-Fields.odt Change-Id: Ic8bc9ed88293a524ff7dea6f865cd6a5d0642988 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196262 Tested-by: Jenkins Reviewed-by: Jim Raykowski --- sw/source/core/undo/rolbck.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 7d10a2624ec0..f5ce46dfd8c7 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -683,15 +683,17 @@ void SwHistoryBookmark::SetInDoc( SwDoc& rDoc, bool ) if(m_bSavePos) { SwContentNode* const pContentNd = rNds[m_nNode]->GetContentNode(); - assert(pContentNd); - oPam.emplace(*pContentNd, m_nContent); + SAL_WARN_IF(!pContentNd, "sw.core", "expected a SwContentNode"); + if (pContentNd) + oPam.emplace(*pContentNd, m_nContent); } else { assert(pMark); oPam.emplace(pMark->GetMarkPos()); } - assert(oPam); + if (!oPam) + return; if(m_bSaveOtherPos) {