diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-13 00:15:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-13 00:15:48 +0000 |
commit | 05d916415f81b10160066eca8c187656940406b9 (patch) | |
tree | 8e3df1d144af38284dedd8db60c3a8d3d3d3f86f /numeric.c | |
parent | 8b4448e2e1461b1d1ba57c40ce2039634629235c (diff) | |
download | ruby-05d916415f81b10160066eca8c187656940406b9.tar.gz |
numeric.c: fix edge case
* numeric.c (rb_fix2str): fix edge case, accidentally generated
wrong Fixnum from LONG_MIN.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -2905,7 +2905,15 @@ rb_fix2str(VALUE x, int base) return rb_usascii_str_new2("0"); } if (val < 0) { - val = -val; + if (val == LONG_MIN) { + int last = ((int)((val = LONG_MAX) % base) + 1); + *--b = ruby_digitmap[last % base]; + val /= base; + val += last == base; /* carry */ + } + else { + val = -val; + } neg = 1; } do { |