Commit c7ff1bd8 authored by Masaki Muranaka's avatar Masaki Muranaka

Add the care for malloc failed.

At the first time, mrb_realloc raise RuntimeError.
At the time fails twice in a row, it causes panic.
parent 29879f9d
......@@ -157,6 +157,20 @@ mrb_realloc(mrb_state *mrb, void *p, size_t len)
mrb_garbage_collect(mrb);
p2 = (mrb->allocf)(mrb, p, len, mrb->ud);
}
if (!p2 && len) {
if (mrb->out_of_memory) {
/* mrb_panic(mrb); */
}
else {
mrb->out_of_memory = 1;
mrb_raise(mrb, E_RUNTIME_ERROR, "Out of memory");
}
}
else {
mrb->out_of_memory = 0;
}
return p2;
}
......
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