summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-07 03:15:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-07 03:15:26 +0000
commit4653fedd0c47e0ceb88fb7dacc2e837268f65664 (patch)
tree6c1de1c7a1bba5cefdf82d901b0f42a043e325ef
parent55724945247c3dde3cf3b96a16ed83c1b25847a2 (diff)
* 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
-rw-r--r--ChangeLog7
-rw-r--r--range.c15
2 files changed, 9 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 584a6b8895e..af750019307 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/range.c b/range.c
index 078219e1848..23217e67b42 100644
--- a/range.c
+++ b/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];