summaryrefslogtreecommitdiff
path: root/comphelper/source/streaming/memorystream.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper/source/streaming/memorystream.cxx')
-rw-r--r--comphelper/source/streaming/memorystream.cxx28
1 files changed, 14 insertions, 14 deletions
diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx
index 4e5beee9d032..b275ac34b06e 100644
--- a/comphelper/source/streaming/memorystream.cxx
+++ b/comphelper/source/streaming/memorystream.cxx
@@ -191,24 +191,24 @@ sal_Int64 SAL_CALL UNOMemoryStream::getLength()
void SAL_CALL UNOMemoryStream::writeBytes( const Sequence< sal_Int8 >& aData )
{
const sal_Int32 nBytesToWrite( aData.getLength() );
- if( nBytesToWrite )
+ if( !nBytesToWrite )
+ return;
+
+ sal_Int64 nNewSize = static_cast<sal_Int64>(mnCursor) + nBytesToWrite;
+ if( nNewSize > SAL_MAX_INT32 )
{
- sal_Int64 nNewSize = static_cast<sal_Int64>(mnCursor) + nBytesToWrite;
- if( nNewSize > SAL_MAX_INT32 )
- {
- OSL_ASSERT(false);
- throw IOException("this implementation does not support more than 2GB!", static_cast<OWeakObject*>(this) );
- }
+ OSL_ASSERT(false);
+ throw IOException("this implementation does not support more than 2GB!", static_cast<OWeakObject*>(this) );
+ }
- if( static_cast< sal_Int32 >( nNewSize ) > static_cast< sal_Int32 >( maData.size() ) )
- maData.resize( nNewSize );
+ if( static_cast< sal_Int32 >( nNewSize ) > static_cast< sal_Int32 >( maData.size() ) )
+ maData.resize( nNewSize );
- sal_Int8* pData = &(*maData.begin());
- sal_Int8* pCursor = &(pData[mnCursor]);
- memcpy( pCursor, aData.getConstArray(), nBytesToWrite );
+ sal_Int8* pData = &(*maData.begin());
+ sal_Int8* pCursor = &(pData[mnCursor]);
+ memcpy( pCursor, aData.getConstArray(), nBytesToWrite );
- mnCursor += nBytesToWrite;
- }
+ mnCursor += nBytesToWrite;
}
void SAL_CALL UNOMemoryStream::flush()