Fix Enumerable#inject with high negative fixnums [Bug #17731]

This commit is contained in:
Marc-Andre Lafortune 2021-03-18 23:29:49 -04:00 committed by Marc-André Lafortune
parent c576e63ee7
commit a85ed626f1
Notes: git 2021-03-19 13:22:07 +09:00
2 changed files with 3 additions and 1 deletions

2
enum.c
View file

@ -805,7 +805,7 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
if (FIXNUM_P(e)) {
n += FIX2LONG(e); /* should not overflow long type */
if (!FIXABLE(n)) {
v = rb_big_plus(ULONG2NUM(n), v);
v = rb_big_plus(LONG2NUM(n), v);
n = 0;
}
}