io/source/stm/streamhelper.cxx |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 24e4b37987ccd410b6d6672151d84c790cdb7e56
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Oct 20 22:42:29 2018 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Oct 21 08:02:01 2018 +0200

    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.kagan...@collabora.com>
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>

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");
         }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to