From 6725491ce8ef2e41feb9b732ad7ac366ba545ca9 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 26 Jun 2018 12:15:19 +0100 Subject: forcepoint#48 null deref Change-Id: I790fc6dafc0d8c9783b9dddc266b313af2a046d7 Reviewed-on: https://gerrit.libreoffice.org/56463 Tested-by: Jenkins Reviewed-by: Christian Lohmaier --- sw/source/core/unocore/unoportenum.cxx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'sw') diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index d40ec5bf5135..043fb179d0fa 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -288,22 +288,25 @@ namespace ::sw::mark::AnnotationMark* const pAnnotationMark = dynamic_cast< ::sw::mark::AnnotationMark* >(ppMark->get()); - if ( pAnnotationMark == nullptr ) - { + if (!pAnnotationMark) continue; - } const SwPosition& rStartPos = pAnnotationMark->GetMarkStart(); - if ( rStartPos.nNode == nOwnNode ) + if (rStartPos.nNode != nOwnNode) + continue; + + const SwFormatField* pAnnotationFormatField = pAnnotationMark->GetAnnotationFormatField(); + if (!pAnnotationFormatField) { - const SwFormatField* pAnnotationFormatField = pAnnotationMark->GetAnnotationFormatField(); - assert(pAnnotationFormatField != nullptr); - rAnnotationStartArr.insert( - std::make_shared( - SwXTextField::CreateXTextField(&rDoc, - pAnnotationFormatField), - rStartPos)); + SAL_WARN("sw.core", "missing annotation format field"); + continue; } + + rAnnotationStartArr.insert( + std::make_shared( + SwXTextField::CreateXTextField(&rDoc, + pAnnotationFormatField), + rStartPos)); } } } -- cgit v1.2.3