mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (rb_ary_cycle): avoid infinite loop for empty array.
based on a patch from David Flanagan. [ruby-core:12085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c19fafb0a4
commit
b3fc59837a
2 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Sep 10 13:44:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_cycle): avoid infinite loop for empty array.
|
||||
based on a patch from David Flanagan. [ruby-core:12085]
|
||||
|
||||
Mon Sep 10 01:21:23 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* marshal.c (r_object0): struct allocation first to check if a
|
||||
|
|
2
array.c
2
array.c
|
@ -2939,7 +2939,7 @@ rb_ary_cycle(VALUE ary)
|
|||
long i;
|
||||
|
||||
RETURN_ENUMERATOR(ary, 0, 0);
|
||||
for (;;) {
|
||||
while (RARRAY_LEN(ary) > 0) {
|
||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||
rb_yield(RARRAY_PTR(ary)[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue