diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-06-19 17:54:27 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-06-19 17:54:27 +0200 |
commit | ef3e481be37a387f6549a561daee890da6712cf5 (patch) | |
tree | 661c0e3a0205a820ab49895b1539769ad915f1d0 /sw/source/filter/ascii | |
parent | d8e7624c9a874aee3ab782715117b118ddd0c496 (diff) |
Do not call SwASC_AttrIter::NextPos when nAktSwPos is already SAL_MAX_INT32
...and calculating nAktSwPos + 1 would overflow. Reported by
CppunitTest_sw_odfexport under -sanitize=undefined.
Change-Id: I78bd540851192a768400ce348b42228f9cb10b72
Diffstat (limited to 'sw/source/filter/ascii')
-rw-r--r-- | sw/source/filter/ascii/ascatr.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx index 1fb879fb2fd4..04a5d890f477 100644 --- a/sw/source/filter/ascii/ascatr.cxx +++ b/sw/source/filter/ascii/ascatr.cxx @@ -197,7 +197,7 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) const bool bExportSoftHyphens = RTL_TEXTENCODING_UCS2 == rWrt.GetAsciiOptions().GetCharSet() || RTL_TEXTENCODING_UTF8 == rWrt.GetAsciiOptions().GetCharSet(); - do { + for (;;) { const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd); if( !aAttrIter.OutAttr( nStrPos )) @@ -209,8 +209,12 @@ static Writer& OutASC_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) rWrt.Strm().WriteUnicodeOrByteText( aOutStr ); } nStrPos = nNextAttr; + if (nStrPos >= nEnd) + { + break; + } aAttrIter.NextPos(); - } while( nStrPos < nEnd ); + } if( !bLastNd || ( ( !rWrt.bWriteClipboardDoc && !rWrt.bASCII_NoLastLineEnd ) |