[Libreoffice-commits] core.git: 2 commits - sw/source
Stephan Bergmann
sbergman at redhat.com
Wed Jan 24 06:55:32 UTC 2018
sw/source/filter/ww8/ww8scan.cxx | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
New commits:
commit 58401e6c8a9f53df96e84d3e1b73c84150890102
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Jan 23 17:06:19 2018 +0100
This presumably always wanted to check for SAL_MAX_UINT16, not USHRT_MAX
The check against USHRT_MAX was introduced together with a following
nLen2 = static_cast<UINT16>(nLen);
in 73f043c441af59da02c160d441b18a73725e62e4 "#96155# #i1858# merge branch and
remove warnings" (and that UINT16 meanwhile replaced with sal_uInt16).
Change-Id: I61346e4ffc90a4f8a97c2d3f822d619faa5b0008
Reviewed-on: https://gerrit.libreoffice.org/48441
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 5cbaefdfd6fd..03696fb5208f 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -4170,8 +4170,8 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen
{
OSL_ENSURE(nLen2 == nLen,
"Fib length and read length are different");
- if (nLen > USHRT_MAX)
- nLen = USHRT_MAX;
+ if (nLen > SAL_MAX_UINT16)
+ nLen = SAL_MAX_UINT16;
else if (nLen < 2 )
nLen = 2;
nLen2 = static_cast<sal_uInt16>(nLen);
commit da67b0be49795ec09a2794dd0fb3e5b29f066dc3
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Jan 23 16:49:08 2018 +0100
Remove presumably dead nLen < USHRT_MAX check
The original code of 7b0b5cdfeed656b279bc32cd929630d5fc25878b "initial import"
read
+ long nLen = ( (nNextPieceCp < nBehindTextCp)
+ ? nNextPieceCp
+ : nBehindTextCp
+ )
+ - nAktStartCp;
+
+ if( 0 >= nLen ) break;
+
+ if( nLen > USHRT_MAX - 1 )
+ nLen = USHRT_MAX - 1;
+
+ if( bIsUnicode )
+ rStr.Append( WW8Read_xstz( rStrm, (USHORT)nLen, FALSE ) );
+ else
+ {
+ ByteString aByteStr; // Alloc methode automatically sets Zero at the end
+ sal_Char* pByteData = aByteStr.AllocBuffer( nLen );
+
+ sal_Size nWasRead = rStrm.Read( pByteData, nLen );
+ if( nWasRead != nLen )
+ aByteStr.ReleaseBufferAccess( nWasRead );
+
+ rStr += String( aByteStr, eEnc );
+ }
+ nTotalRead += nLen;
+ nAktStartCp += nLen;
+ if( nTotalRead != rStr.Len() ) break;
casting nLen to USHORT in the call to WW8Read_xstz, while the current code looks
like it should work fine for larger nLen.
Change-Id: Ie3a0d654ef45421cbbe8e823259e8dfd27bd27e2
Reviewed-on: https://gerrit.libreoffice.org/48437
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index dd8d2479233a..5cbaefdfd6fd 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2050,9 +2050,6 @@ sal_Int32 WW8ScannerBase::WW8ReadString( SvStream& rStrm, OUString& rStr,
if (bFail)
break;
- if( nLen > USHRT_MAX - 1 )
- nLen = USHRT_MAX - 1;
-
if( 0 >= nLen )
break;
More information about the Libreoffice-commits
mailing list