Commit 97545127 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #568 from mauceri/master

Potential memory management bug (issue #553)
parents 6583c966 186fd9a3
......@@ -2079,6 +2079,10 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *lv)
p->nlocals = p->sp;
p->ai = mrb->arena_idx;
//because of a potential bad memory access in case of gc let's allocate the irep right now
mrb_add_irep(mrb, mrb->irep_len);
mrb->irep[mrb->irep_len] = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep));
mrb->irep[mrb->irep_len]->plen = 0;
p->idx = mrb->irep_len++;
p->filename = prev->filename;
if (p->filename) {
......@@ -2092,10 +2096,12 @@ scope_finish(codegen_scope *s, int idx)
{
mrb_state *mrb = s->mrb;
mrb_irep *irep;
mrb_add_irep(mrb, idx);
irep = mrb->irep[idx] = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep));
//Comment out these instructions already done in scope_new
//mrb_add_irep(mrb, idx);
//irep = mrb->irep[idx] = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep));
irep = mrb->irep[idx];
irep->flags = 0;
irep->idx = idx;
if (s->iseq) {
......
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