Kaydet (Commit) 86fd9622 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_pBuffer' is lost. Consider assigning realloc()
     to a temporary pointer.

Change-Id: I8a18e1472072456bfe9f32d822f185cabd24d6ed
Reviewed-on: https://gerrit.libreoffice.org/62114Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
Tested-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 3846561f
......@@ -88,7 +88,10 @@ int MemoryContainer::append(
m_nLen+=1024;
} while(m_nLen < tmp);
m_pBuffer = std::realloc(m_pBuffer,m_nLen);
if (auto p = std::realloc(m_pBuffer, m_nLen))
m_pBuffer = p;
else
return 0;
}
memcpy(static_cast<sal_Int8*>(m_pBuffer)+m_nWritePos,
......
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