[Libreoffice-commits] core.git: io/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Oct 21 06:02:22 UTC 2018
io/source/stm/streamhelper.cxx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
New commits:
commit 24e4b37987ccd410b6d6672151d84c790cdb7e56
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sat Oct 20 22:42:29 2018 +0200
Commit: Mike Kaganski <mike.kaganski at 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.kaganski at collabora.com>
Tested-by: Mike Kaganski <mike.kaganski at 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");
}
More information about the Libreoffice-commits
mailing list