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 | f58f44eec66bce06f6ce2bdc4043b195f5e3421a (patch) | |
tree | 8e3df1d144af38284dedd8db60c3a8d3d3d3f86f /numeric.c | |
parent | d5671da40c8dd7ed6642950cab6d73c8378a8328 (diff) | |
download | ruby-f58f44eec66bce06f6ce2bdc4043b195f5e3421a.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 { |