summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-17 08:31:07 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-17 08:31:07 +0000
commit5a0dc000168658915906a4300b21fb9073ce1b76 (patch)
tree1e75936d6190e83ca622543a5f79ab8d49545147
parentf9ea2d5ea2abbd64f77e474a2d2bb3d17710655e (diff)
downloadruby-5a0dc000168658915906a4300b21fb9073ce1b76.tar.gz
ruby-5a0dc000168658915906a4300b21fb9073ce1b76.tar.xz
ruby-5a0dc000168658915906a4300b21fb9073ce1b76.zip
* bignum.c (big_split): fix off-by-one error. [ruby-dev:39501]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 07b188317..0c4314ba5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Oct 17 17:30:06 2009 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * bignum.c (big_split): fix off-by-one error. [ruby-dev:39501]
+
Sat Oct 17 16:34:27 2009 Tanaka Akira <akr@fsij.org>
* parse.y (parser_yylex): fix token even after trailing under score.
diff --git a/bignum.c b/bignum.c
index 44775ff7f..df66d3366 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1848,13 +1848,13 @@ big_split(VALUE v, long n, volatile VALUE *ph, volatile VALUE *pl)
while (--hn && !vds[hn + ln]);
h = bignew(hn += 2, 1);
- MEMCPY(BDIGITS(h), vds + ln, BDIGIT, hn);
- BDIGITS(h)[hn - 1] = 0;
+ MEMCPY(BDIGITS(h), vds + ln, BDIGIT, hn - 1);
+ BDIGITS(h)[hn - 1] = 0; /* margin for carry */
while (--ln && !vds[ln]);
l = bignew(ln += 2, 1);
- MEMCPY(BDIGITS(l), vds, BDIGIT, ln);
- BDIGITS(l)[ln - 1] = 0;
+ MEMCPY(BDIGITS(l), vds, BDIGIT, ln - 1);
+ BDIGITS(l)[ln - 1] = 0; /* margin for carry */
*pl = l;
*ph = h;