diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-10-20 22:42:29 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-10-21 08:02:01 +0200 |
commit | 24e4b37987ccd410b6d6672151d84c790cdb7e56 (patch) | |
tree | 5036d0571c38d033285d4c41c9cea8b8725efb2e /io | |
parent | 79e837d8e2fb961cd4825566f07aabf031fddb5f (diff) |
tdf#120703 (PVS): handle failed realloc
V701 realloc() possible leak: when realloc() fails in allocating memory,
original pointer 'm_p' is lost. Consider assigning realloc() to a
temporary pointer.
Change-Id: Ic298927a266da4d543f3856a1c9f97ba1f6fe941
Reviewed-on: https://gerrit.libreoffice.org/62092
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'io')
-rw-r--r-- | io/source/stm/streamhelper.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/io/source/stm/streamhelper.cxx b/io/source/stm/streamhelper.cxx index 0ef0d3e1f7ae..c382cae96390 100644 --- a/io/source/stm/streamhelper.cxx +++ b/io/source/stm/streamhelper.cxx @@ -75,8 +75,10 @@ void MemRingBuffer::resizeBuffer( sal_Int32 nMinSize ) } if( nNewLen != m_nBufferLen ) { - m_p = static_cast<sal_Int8 *>(std::realloc( m_p , nNewLen )); - if( !m_p ) { + if (auto p = static_cast<sal_Int8*>(std::realloc(m_p, nNewLen))) + m_p = p; + else + { throw css::io::BufferSizeExceededException( "MemRingBuffer::resizeBuffer BufferSizeExceededException"); } |