diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-02-16 09:20:12 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-16 14:34:47 +0100 |
commit | 62aba0e74c849bdb82b1b3aaac93a63914f98e41 (patch) | |
tree | adbcb1d70e26c880b2805d7af8dbc097fbdef8cb /tools | |
parent | e7c67eb093d1e099225eaccdaaf29eff1a4c9325 (diff) |
Resolves: tdf#115750 SvStream::WriteStream was broken
and didn't stop copying at the size limit arg
Change-Id: I8f1be0310160f5158d2f64c62d6b2c09c0157930
Reviewed-on: https://gerrit.libreoffice.org/49839
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/stream/stream.cxx | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 4c363dc67484..e7b3ccd20ae6 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1187,13 +1187,12 @@ sal_uInt64 SvStream::WriteStream( SvStream& rStream, sal_uInt64 nSize ) sal_uInt32 nCount; sal_uInt64 nWriteSize = nSize; - do { - if ( nSize >= nCurBufLen ) - nWriteSize -= nCurBufLen; - else - nCurBufLen = nWriteSize; - nCount = rStream.ReadBytes( pBuf.get(), nCurBufLen ); + do + { + nCurBufLen = std::min<sal_uInt64>(nCurBufLen, nWriteSize); + nCount = rStream.ReadBytes(pBuf.get(), nCurBufLen); WriteBytes( pBuf.get(), nCount ); + nWriteSize -= nCount; } while( nWriteSize && nCount == nCurBufLen ); |