Permalink
Browse files

fix off by one error in region->num_regs usage

  • Loading branch information...
1 parent 118a1ee commit e081eff9ffcb4891bf8b11a853d4f3c4f531f7cc Nikolai Lugovoi committed Mar 26, 2007
Showing with 4 additions and 4 deletions.
  1. +4 −4 ext/oregexp.c
View
@@ -169,12 +169,12 @@ static VALUE oregexp_make_match_data(ORegexp * oregexp, OnigRegion * region, VAL
match->str = rb_str_new4(string_str);
match->regs = ALLOC(struct re_registers);
- match->regs->allocated = count+1;
+ match->regs->allocated = count;
match->regs->num_regs = count;
- match->regs->beg = ALLOC_N(int, (count+1));
- match->regs->end = ALLOC_N(int, (count+1));
+ match->regs->beg = ALLOC_N(int, count);
+ match->regs->end = ALLOC_N(int, count);
- for ( i = 0; i <= count; i++){
+ for ( i = 0; i < count; i++){
match->regs->beg[i] = region->beg[i];
match->regs->end[i] = region->end[i];
}

0 comments on commit e081eff

Please sign in to comment.