Skip to content
Permalink
Browse files

Clear unused stack region that may refer freed objects; fix #3596

  • Loading branch information...
matz committed Apr 10, 2017
1 parent 491d68b commit 5c114c91d4ff31859fcd84cf8bf349b737b90d99
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/gc.c
@@ -544,6 +544,7 @@ mark_context_stack(mrb_state *mrb, struct mrb_context *c)
{
size_t i;
size_t e;
mrb_value nil;

if (c->stack == NULL) return;
e = c->stack - c->stbase;
@@ -553,14 +554,14 @@ mark_context_stack(mrb_state *mrb, struct mrb_context *c)
mrb_value v = c->stbase[i];

if (!mrb_immediate_p(v)) {
if (mrb_basic_ptr(v)->tt == MRB_TT_FREE) {
c->stbase[i] = mrb_nil_value();
}
else {
mrb_gc_mark(mrb, mrb_basic_ptr(v));
}
mrb_gc_mark(mrb, mrb_basic_ptr(v));
}
}
e = c->stend - c->stbase;
nil = mrb_nil_value();
for (; i<e; i++) {
c->stbase[i] = nil;
}
}

static void

0 comments on commit 5c114c9

Please sign in to comment.
You can’t perform that action at this time.