Actions
Bug #2227
closedinvalid memory access in 100**900
Description
=begin
遠藤です。
2009年10月17日9:01 Tanaka Akira akr@fsij.org:
以下のように、100**900 を計算すると変なところをアクセスするようです。
すみません、off-by-one エラーしてました。
Index: bignum.c¶
--- bignum.c (revision 25382)
+++ bignum.c (working copy)
@@ -1848,13 +1848,13 @@
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;
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Actions
Like0
Like0Like0