diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | bignum.c | 11 |
2 files changed, 13 insertions, 2 deletions
@@ -1,3 +1,7 @@ +Mon Oct 30 12:20:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org> + + * bignum.c (rb_big2str0): a bug in length adjustment. + Mon Oct 30 11:15:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org> * sprintf.c (rb_str_format): should preserve leading zero @@ -691,8 +691,15 @@ rb_big2str0(x, base, trim) } } if (trim) {while (s[j] == '0') j++;} - RSTRING(ss)->len -= RBIGNUM(x)->sign?j:j-1; - memmove(RBIGNUM(x)->sign?s:s+1, s+j, RSTRING(ss)->len); + i = RSTRING(ss)->len - j; + if (RBIGNUM(x)->sign) { + memmove(s, s+j, i); + RSTRING(ss)->len = i-1; + } + else { + memmove(s+1, s+j, i); + RSTRING(ss)->len = i; + } s[RSTRING(ss)->len] = '\0'; return ss; |