diff options
| author | Christian Mauceri <[email protected]> | 2012-11-22 12:55:03 +0100 |
|---|---|---|
| committer | Christian Mauceri <[email protected]> | 2012-11-22 12:55:03 +0100 |
| commit | 06ca237babe430fc4fcb79a696730b7511b4b7fe (patch) | |
| tree | 94df041fbc0e5cf061b9bec21da37571a5faac68 /src | |
| parent | 1b2257c8ff212d1069b00e11a6b91672c9636ecb (diff) | |
| download | mruby-06ca237babe430fc4fcb79a696730b7511b4b7fe.tar.gz mruby-06ca237babe430fc4fcb79a696730b7511b4b7fe.zip | |
pull request issue 553
Diffstat (limited to 'src')
| -rw-r--r-- | src/codegen.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/codegen.c b/src/codegen.c index f37a9e331..6f63c3d0e 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -2080,6 +2080,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)); + p->idx = mrb->irep_len++; p->filename = prev->filename; if (p->filename) { @@ -2093,10 +2097,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) { |
