Fix a memory leak in mrb_realloc().

This commit is contained in:
Masaki Muranaka
2012-08-03 14:03:53 +09:00
parent 6fb88f7e1d
commit 81b41e84e9
+6 -4
View File
@@ -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*