mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Using mrb_realloc() with stack_extend_alloc()
Raising a `SystemStackError` exception in an out-of-memory situation will generate backtrace information.
This can eventually lead to a `NoMemoryError` exception, and this process flow is completely undesirable.
In effect, this change means that it will include a revert of commit 0dbb9e6e41.
This commit is contained in:
@@ -177,10 +177,7 @@ stack_extend_alloc(mrb_state *mrb, mrb_int room)
|
||||
size += room;
|
||||
#endif
|
||||
|
||||
newstack = (mrb_value *)mrb_realloc_simple(mrb, mrb->c->stbase, sizeof(mrb_value) * size);
|
||||
if (newstack == NULL) {
|
||||
mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
|
||||
}
|
||||
newstack = (mrb_value *)mrb_realloc(mrb, mrb->c->stbase, sizeof(mrb_value) * size);
|
||||
stack_clear(&(newstack[oldsize]), size - oldsize);
|
||||
envadjust(mrb, oldbase, newstack, oldsize);
|
||||
mrb->c->stbase = newstack;
|
||||
|
||||
Reference in New Issue
Block a user