summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-12-30 13:57:38 +0000
committerAndras Timar <andras.timar@collabora.com>2021-05-10 16:33:51 +0200
commit4d099da8d2ab9de871c45c35fd7c7afa18aac893 (patch)
tree69af23b07ca859ddff618df6d8468967b49858ce
parent6b7b27e043fdcc87ab7caf34fcc1919cc2b15541 (diff)
ofz#4837 Null-dereference READ
Change-Id: I7e4cb934aeac32fa1170beb116e4600b5eb9389a Reviewed-on: https://gerrit.libreoffice.org/47197 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 9f8dd17b1e6ab5d5d07b61e0f85edea233f03d71)
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index d404d6c9c29c..e6e763f4123a 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -559,6 +559,15 @@ public:
}
};
+namespace
+{
+ bool IsValidSel(const EditEngine& rEngine, const ESelection& rSel)
+ {
+ const auto nParaCount = rEngine.GetParagraphCount();
+ return rSel.nStartPara < nParaCount && rSel.nEndPara < nParaCount;
+ }
+}
+
// InsertAttrsAsDrawingAttrs() sets attributes between StartCp and EndCp.
// Style attributes are set as hard, paragraph and character attributes.
void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
@@ -733,6 +742,8 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
{
ESelection aSel(GetESelection(*m_pDrawEditEngine, aIter->GetStartPos()-nStartCp,
aIter->GetEndPos()-nStartCp));
+ if (!IsValidSel(*m_pDrawEditEngine, aSel))
+ continue;
OUString aString(m_pDrawEditEngine->GetText(aSel));
const sal_Int32 nOrigLen = aString.getLength();
WW8_CP nDummy(0);