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): check was done with false pointer.

[ruby-dev:24383]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-10-02 03:49:15 +00:00
parent 7665754a5a
commit 9d923be604
2 changed files with 7 additions and 4 deletions

View file

@ -1,5 +1,8 @@
Sat Oct 2 00:42:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_sum): check was done with false pointer.
[ruby-dev:24383]
* string.c (rb_str_sum): string may be altered. [ruby-dev:24381]
Fri Oct 1 11:40:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>

View file

@ -4405,7 +4405,7 @@ rb_str_sum(argc, argv, str)
{
VALUE vbits;
int bits;
char *p, *pend;
char *ptr, *p, *pend;
long len;
if (rb_scan_args(argc, argv, "01", &vbits) == 0) {
@ -4413,7 +4413,7 @@ rb_str_sum(argc, argv, str)
}
else bits = NUM2INT(vbits);
p = RSTRING(str)->ptr;
ptr = p = RSTRING(str)->ptr;
len = RSTRING(str)->len;
pend = p + len;
if (bits > sizeof(long)*CHAR_BIT) {
@ -4424,7 +4424,7 @@ rb_str_sum(argc, argv, str)
mod = rb_funcall(mod, '-', 1, INT2FIX(1));
while (p < pend) {
str_mod_check(str, p, len);
str_mod_check(str, ptr, len);
res = rb_funcall(res, '+', 1, INT2FIX((unsigned int)*p));
p++;
}
@ -4439,7 +4439,7 @@ rb_str_sum(argc, argv, str)
mod = -1;
}
while (p < pend) {
str_mod_check(str, p, len);
str_mod_check(str, ptr, len);
res += (unsigned int)*p;
p++;
}