summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-30 03:24:19 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-30 03:24:19 +0000
commit0acc3f9bd831e1c75c429c3d76c92b8e22b3f035 (patch)
tree0d1f6e7bee810429137989540bb88275db344d63
parentbba7c7be867df3dfad760fcc15cb08b7548a86e1 (diff)
downloadruby-0acc3f9bd831e1c75c429c3d76c92b8e22b3f035.tar.gz
ruby-0acc3f9bd831e1c75c429c3d76c92b8e22b3f035.tar.xz
ruby-0acc3f9bd831e1c75c429c3d76c92b8e22b3f035.zip
* bignum.c (rb_big2str0): a bug in length adjustment.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@11238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c11
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f0c976f63..9d803d0e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/bignum.c b/bignum.c
index 50bd490e4..04d438445 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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;