Kaydet (Commit) 24e4b379 authored tarafından Mike Kaganski's avatar Mike Kaganski

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/62092Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
Tested-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 79e837d8
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment