diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-02-16 09:20:12 +0000 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-05-04 16:59:36 +0200 |
commit | ba8768e43fe357f2049659b6fc1ef6c13a1c74ef (patch) | |
tree | 83fddbd81c2683d2b97baed43379ba81c3637082 | |
parent | 9394cb57ecb24160649d7e3188c75f64d810ca51 (diff) |
Resolves: tdf#115750 SvStream::WriteStream was broken
and didn't stop copying at the size limit arg
(cherry picked from commit bcdaaf62d41728eb757ff2b9cb95c2df2791e2f4)
Change-Id: I8f1be0310160f5158d2f64c62d6b2c09c0157930
-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 b83729e35fbf..530f6e8c0620 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1184,13 +1184,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 ); |