summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-12-30 13:57:38 +0000
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-29 07:51:48 +0100
commit2d57933b451b57689e1036bf96eb67bd1fdf86ab (patch)
tree03ea155c7e19d3f2365d24c65f1f2ba8f4e89227
parentf32b9fe9661ac90dd2f20ce7f7f21ab6018e6d61 (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);