mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
random.c: fixed seed underflow bug.
`MRB_INT_MIN` does not have a corresponding positive value.
This commit is contained in:
@@ -152,6 +152,9 @@ get_opt(mrb_state* mrb)
|
||||
arg = mrb_to_int(mrb, arg);
|
||||
i = mrb_integer(arg);
|
||||
if (i < 0) {
|
||||
if (i == MRB_INT_MIN) {
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "integer underflow");
|
||||
}
|
||||
arg = mrb_fixnum_value(0 - i);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user