diff --git a/ChangeLog b/ChangeLog index 0b2d36bf09..e6c63f6e3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Dec 20 09:42:11 2007 Yukihiro Matsumoto + + * bignum.c (big2str_orig): access beyond memory region cause crash + on interrupt. a patch from Yusuke ENDOH in + [ruby-dev:32651]. [ruby-dev:32641] + Thu Dec 20 09:06:54 2007 Yukihiro Matsumoto * string.c (rb_str_index): wrong starting position. diff --git a/bignum.c b/bignum.c index 8e2ae98bcd..39afad90c5 100644 --- a/bignum.c +++ b/bignum.c @@ -837,12 +837,12 @@ big2str_orig(VALUE x, int base, char* ptr, long len, long hbase, int trim) while (k--) { ptr[--j] = ruby_digitmap[num % base]; num /= base; - if (!trim && j <= 0) break; + if (j <= 0) break; if (trim && i == 0 && num == 0) break; } } if (trim) { - while (ptr[j] == '0') j++; + while (j < len && ptr[j] == '0') j++; MEMMOVE(ptr, ptr + j, char, len - j); len -= j; }