Commit 81b41e84 authored by Masaki Muranaka's avatar Masaki Muranaka

Fix a memory leak in mrb_realloc().

parent 6fb88f7e
......@@ -151,13 +151,15 @@ gettimeofday_time(void)
void*
mrb_realloc(mrb_state *mrb, void *p, size_t len)
{
p = (mrb->allocf)(mrb, p, len);
void *p2;
if (!p && len > 0 && mrb->heaps) {
p2 = (mrb->allocf)(mrb, p, len);
if (!p2 && len > 0 && mrb->heaps) {
mrb_garbage_collect(mrb);
p = (mrb->allocf)(mrb, p, len);
p2 = (mrb->allocf)(mrb, p, len);
}
return p;
return p2;
}
void*
......
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