1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* bignum.c (big2str_orig): access beyond memory region cause crash

on interrupt.  a patch from Yusuke ENDOH <mame AT tsg.ne.jp> in 
  [ruby-dev:32651].  [ruby-dev:32641]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-12-20 00:43:39 +00:00
parent 1c32ff927f
commit 9a82a62937
2 changed files with 8 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Thu Dec 20 09:42:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* bignum.c (big2str_orig): access beyond memory region cause crash
on interrupt. a patch from Yusuke ENDOH <mame AT tsg.ne.jp> in
[ruby-dev:32651]. [ruby-dev:32641]
Thu Dec 20 09:06:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Thu Dec 20 09:06:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_index): wrong starting position. * string.c (rb_str_index): wrong starting position.

View file

@ -837,12 +837,12 @@ big2str_orig(VALUE x, int base, char* ptr, long len, long hbase, int trim)
while (k--) { while (k--) {
ptr[--j] = ruby_digitmap[num % base]; ptr[--j] = ruby_digitmap[num % base];
num /= base; num /= base;
if (!trim && j <= 0) break; if (j <= 0) break;
if (trim && i == 0 && num == 0) break; if (trim && i == 0 && num == 0) break;
} }
} }
if (trim) { if (trim) {
while (ptr[j] == '0') j++; while (j < len && ptr[j] == '0') j++;
MEMMOVE(ptr, ptr + j, char, len - j); MEMMOVE(ptr, ptr + j, char, len - j);
len -= j; len -= j;
} }