Fixes #80 ("realloc in interprocess's c_heap_deleter can leak memory")

This commit is contained in:
Ion Gaztañaga
2019-03-13 22:54:33 +01:00
parent d5938226a9
commit 4744b9a24e

View File

@@ -1862,10 +1862,10 @@ class c_heap_deleter
void realloc_mem(std::size_t num_bytes)
{
void *buf = ::realloc(m_buf, num_bytes);
if(!buf){
free(m_buf);
m_buf = 0;
void *oldBuf = m_buf;
m_buf = ::realloc(m_buf, num_bytes);
if (!m_buf){
free(oldBuf);
}
}