Fix realloc leak on out-of-memory

This commit is contained in:
Wilson Snyder 2017-07-12 18:54:27 -04:00
parent 13f790360d
commit 88cf5e5d98
1 changed files with 3 additions and 2 deletions

View File

@ -44,8 +44,9 @@ private:
if (m_dataSize<point) m_dataSize=(point+64) & ~63ULL; // Keep power of two
m_dataSize *= 2;
//UINFO(9, "Realloc "<<allocSize()<<" for "<<point<<" "<<(void*)(m_datap)<<endl);
m_datap = (vluint64_t*)realloc(m_datap, allocSize());
if (!m_datap) {v3fatal("Out of memory increasing buckets"); }
vluint64_t* newp = (vluint64_t*)realloc(m_datap, allocSize());
if (!newp) { free(m_datap); v3fatal("Out of memory increasing buckets"); }
m_datap = newp;
for (vluint64_t i=oldsize; i<m_dataSize; i+=64) m_datap[i/64] = 0;
}