Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refer to irep_capa as well as irep_len when irep is marked by GC.

Initialize mrb->irep array with 0 when realloc is called.
  • Loading branch information...
commit a851bcd631e9a8953f29b4f63ad0354ee775e02e 1 parent 72bc9c8
@masamitsu-murase masamitsu-murase authored
Showing with 6 additions and 2 deletions.
  1. +4 −2 src/gc.c
  2. +2 −0  src/state.c
View
6 src/gc.c
@@ -587,8 +587,10 @@ root_scan_phase(mrb_state *mrb)
mrb_gc_mark(mrb, (struct RBasic*)ci->target_class);
}
/* mark irep pool */
- for (i=0; i<mrb->irep_len; i++) {
- if (mrb->irep) {
+ if (mrb->irep) {
+ size_t len = mrb->irep_len;
+ if (len > mrb->irep_capa) len = mrb->irep_capa;
+ for (i=0; i<len; i++) {
mrb_irep *irep = mrb->irep[i];
if (!irep) continue;
for (j=0; j<irep->plen; j++) {
View
2  src/state.c
@@ -83,10 +83,12 @@ mrb_add_irep(mrb_state *mrb, int idx)
mrb->irep_capa = max;
}
else if (mrb->irep_capa <= idx) {
+ size_t old_capa = mrb->irep_capa;
while (mrb->irep_capa <= idx) {
mrb->irep_capa *= 2;
}
mrb->irep = (mrb_irep **)mrb_realloc(mrb, mrb->irep, sizeof(mrb_irep*)*mrb->irep_capa);
+ memset(mrb->irep + old_capa, 0, sizeof(mrb_irep*) * (mrb->irep_capa - old_capa));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.