diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-12-02 19:17:13 -0800 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-12-02 19:17:13 -0800 |
| commit | 97545127162aca8354c2436308bf1f5b284a2340 (patch) | |
| tree | 1d2bd63ad5a18c215544dff3652a68cdd3b1aa89 /src/codegen.c | |
| parent | 6583c96640c375141b955e0f6f45835095266361 (diff) | |
| parent | 186fd9a3039c484849006ac114d084b85526fdab (diff) | |
| download | mruby-97545127162aca8354c2436308bf1f5b284a2340.tar.gz mruby-97545127162aca8354c2436308bf1f5b284a2340.zip | |
Merge pull request #568 from mauceri/master
Potential memory management bug (issue #553)
Diffstat (limited to 'src/codegen.c')
| -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 1e468867c..a6c94d871 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -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) { |
