diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-21 15:04:57 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-22 12:43:56 +0200 |
commit | 78490b45c771a4c9632b324922f2c8e83f06153b (patch) | |
tree | 0e74de3a28bce5a7300f39aa36378d35eedc0afe /tools | |
parent | 5c147fc5fe0e77838b8e9bebd4ff215a80946980 (diff) |
pvs-studio: V668 no sense testing against null as memory was allocated by new
category V668 complete
Change-Id: I986d4cb89a7c72d54d71ea01fc598a9958deee24
Reviewed-on: https://gerrit.libreoffice.org/62138
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/config.cxx | 15 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 22 |
2 files changed, 10 insertions, 27 deletions
diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx index a9ee7f1cc274..f27542070fb2 100644 --- a/tools/source/generic/config.cxx +++ b/tools/source/generic/config.cxx @@ -410,21 +410,14 @@ static sal_uInt8* ImplGetConfigBuffer( const ImplConfigData* pData, sal_uInt32& if ( !nBufLen ) { pWriteBuf = new sal_uInt8[nLineEndLen]; - if ( pWriteBuf ) - { - pWriteBuf[0] = aLineEndBuf[0]; - if ( nLineEndLen == 2 ) - pWriteBuf[1] = aLineEndBuf[1]; - return pWriteBuf; - } - else - return nullptr; + pWriteBuf[0] = aLineEndBuf[0]; + if ( nLineEndLen == 2 ) + pWriteBuf[1] = aLineEndBuf[1]; + return pWriteBuf; } // Allocate new write buffer (caller frees it) pWriteBuf = new sal_uInt8[nBufLen]; - if ( !pWriteBuf ) - return nullptr; // fill buffer pBuf = pWriteBuf; diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 21b317e774b9..e7d21d950e39 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1632,13 +1632,9 @@ SvMemoryStream::SvMemoryStream( std::size_t nInitSize, std::size_t nResizeOffset pBuf = nullptr; if( nResize != 0 && nResize < 16 ) nResize = 16; - if( nInitSize && !AllocateMemory( nInitSize ) ) - { - SetError( SVSTREAM_OUTOFMEMORY ); - nSize = 0; - } - else - nSize = nInitSize; + if( nInitSize ) + AllocateMemory( nInitSize ); + nSize = nInitSize; SetBufferSize( 64 ); } @@ -1801,10 +1797,9 @@ void SvMemoryStream::ResetError() SvStream::ClearError(); } -bool SvMemoryStream::AllocateMemory( std::size_t nNewSize ) +void SvMemoryStream::AllocateMemory( std::size_t nNewSize ) { pBuf = new sal_uInt8[nNewSize]; - return( pBuf != nullptr ); } // (using Bozo algorithm) @@ -1887,13 +1882,8 @@ void* SvMemoryStream::SwitchBuffer() ResetError(); std::size_t nInitSize = 512; - if( !AllocateMemory(nInitSize) ) - { - SetError( SVSTREAM_OUTOFMEMORY ); - nSize = 0; - } - else - nSize = nInitSize; + AllocateMemory(nInitSize); + nSize = nInitSize; SetBufferSize( 64 ); return pRetVal; |