mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fixed possible inconsistency in gc_protect()
If `mrb_realloc()` raises an out-of-memory exception, `arena_capa` will hold the wrong value.
This commit is contained in:
@@ -459,8 +459,9 @@ gc_protect(mrb_state *mrb, mrb_gc *gc, struct RBasic *p)
|
||||
#else
|
||||
if (gc->arena_idx >= gc->arena_capa) {
|
||||
/* extend arena */
|
||||
gc->arena_capa = (int)(gc->arena_capa * 3 / 2);
|
||||
gc->arena = (struct RBasic**)mrb_realloc(mrb, gc->arena, sizeof(struct RBasic*)*gc->arena_capa);
|
||||
int newcapa = gc->arena_capa * 3 / 2;
|
||||
gc->arena = (struct RBasic**)mrb_realloc(mrb, gc->arena, sizeof(struct RBasic*)*newcapa);
|
||||
gc->arena_capa = newcapa;
|
||||
}
|
||||
#endif
|
||||
gc->arena[gc->arena_idx++] = p;
|
||||
|
||||
Reference in New Issue
Block a user