mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (rb_ary_sample): get rid of infinite loop. #455
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f78380f0f1
commit
6523eee836
2 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
Wed Aug 20 12:28:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_sample): get rid of infinite loop. #455
|
||||
|
||||
Wed Aug 20 06:09:31 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/io.h (FMODE_TRUNC): value changed because 0x100 is used
|
||||
|
|
3
array.c
3
array.c
|
@ -3032,8 +3032,9 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary)
|
|||
return RARRAY_PTR(ary)[i];
|
||||
}
|
||||
rb_scan_args(argc, argv, "1", &nv);
|
||||
if (len == 0) return rb_ary_new2(0);
|
||||
n = NUM2INT(nv);
|
||||
if (n > len) n = len;
|
||||
if (n == 0) return rb_ary_new2(0);
|
||||
result = rb_ary_new2(n);
|
||||
for (i=0; i<n; i++) {
|
||||
retry:
|
||||
|
|
Loading…
Reference in a new issue