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

* string.c (rb_str_sum): should use bignums when bits is greater

than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-10-02 11:30:40 +00:00
parent 779f3d6d11
commit 77636d0364
3 changed files with 8 additions and 2 deletions

View file

@ -1,5 +1,11 @@
Sat Oct 2 00:42:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_sum): should use bignums when bits is greater
than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395]
* eval.c (specific_eval): defer pointer retrieval to prevent
unsafe sourcefile string modification. [ruby-dev:24382]
* string.c (rb_str_sum): wrong cast caused wrong result.
[ruby-dev:24385]

2
eval.c
View file

@ -6322,10 +6322,10 @@ specific_eval(argc, argv, klass, self)
rb_id2name(ruby_frame->last_func),
rb_id2name(ruby_frame->last_func));
}
if (argc > 2) line = NUM2INT(argv[2]);
if (argc > 1) {
file = StringValuePtr(argv[1]);
}
if (argc > 2) line = NUM2INT(argv[2]);
}
return eval_under(klass, self, argv[0], file, line);
}

View file

@ -4416,7 +4416,7 @@ rb_str_sum(argc, argv, str)
ptr = p = RSTRING(str)->ptr;
len = RSTRING(str)->len;
pend = p + len;
if (bits > sizeof(long)*CHAR_BIT) {
if (bits >= sizeof(long)*CHAR_BIT) {
VALUE sum = INT2FIX(0);
while (p < pend) {