Skip to content

Commit

Permalink
Merge pull request #6261 from leviongit/range/to_a
Browse files Browse the repository at this point in the history
fix: `to_a` integer ranges with `begin > end` failing
  • Loading branch information
matz committed May 9, 2024
2 parents 06480f7 + fff07ca commit aac9e4c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/range.c
Expand Up @@ -358,6 +358,10 @@ range_num_to_a(mrb_state *mrb, mrb_value range)
if (mrb_integer_p(end)) {
mrb_int a = mrb_integer(beg);
mrb_int b = mrb_integer(end);

if (a > b) {
return mrb_ary_new_capa(mrb, 0);
}
mrb_int len;

if (mrb_int_sub_overflow(b, a, &len)) {
Expand Down

0 comments on commit aac9e4c

Please sign in to comment.