From 77636d0364d5df961834b64bff1a3bc8f50ce259 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 2 Oct 2004 11:30:40 +0000 Subject: [PATCH] * 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 --- ChangeLog | 6 ++++++ eval.c | 2 +- string.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4e2f18a07..c2b1929f74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ Sat Oct 2 00:42:20 2004 Yukihiro Matsumoto + * 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] diff --git a/eval.c b/eval.c index 76726f012f..5b4cfe3b03 100644 --- a/eval.c +++ b/eval.c @@ -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); } diff --git a/string.c b/string.c index c6e43fd212..ac87b8d68f 100644 --- a/string.c +++ b/string.c @@ -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) {