summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/source/stream/stream.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 3a9f767880dd..5d6d3e58336b 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1186,13 +1186,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 );