* range.c (range_each_func): should not leave a variable

uninitialized, which could cause SEGV.

* range.c (range_step): removed duplicated and unreachable code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-04-07 03:15:26 +00:00
Родитель 5572494524
Коммит 4653fedd0c
2 изменённых файлов: 9 добавлений и 13 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Mon Apr 7 12:15:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* range.c (range_each_func): should not leave a variable
uninitialized, which could cause SEGV.
* range.c (range_step): removed duplicated and unreachable code.
Mon Apr 7 02:12:27 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_intern): need not to check if tainted.

15
range.c
Просмотреть файл

@ -228,7 +228,7 @@ range_each_func(VALUE range, VALUE (*func) (VALUE, void *), void *arg)
int c;
VALUE b = RANGE_BEG(range);
VALUE e = RANGE_END(range);
VALUE v;
VALUE v = b;
if (EXCL(range)) {
while (r_lt(v, e)) {
@ -295,9 +295,8 @@ step_i(VALUE i, void *arg)
static VALUE
range_step(int argc, VALUE *argv, VALUE range)
{
VALUE b, e, step, tmp, c;
VALUE b, e, step, tmp;
long unit;
int nv;
RETURN_ENUMERATOR(range, argc, argv);
@ -361,16 +360,6 @@ range_step(int argc, VALUE *argv, VALUE range)
iter[1] = step;
rb_block_call(b, rb_intern("upto"), 2, args, step_i, (VALUE)iter);
}
else if (rb_obj_is_kind_of(b, rb_cNumeric)) {
ID c = rb_intern(EXCL(range) ? "<" : "<=");
if (rb_equal(step, INT2FIX(0)))
rb_raise(rb_eArgError, "step can't be 0");
while (RTEST(rb_funcall(b, c, 1, e))) {
rb_yield(b);
b = rb_funcall(b, '+', 1, step);
}
}
else {
VALUE args[2];