From 9a82a62937ab8978766b5f88208e8c44d9f6941a Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 20 Dec 2007 00:43:39 +0000 Subject: [PATCH] * bignum.c (big2str_orig): access beyond memory region cause crash on interrupt. a patch from Yusuke ENDOH in [ruby-dev:32651]. [ruby-dev:32641] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ bignum.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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; }