diff options
| author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-06 21:43:46 +0000 |
|---|---|---|
| committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-06 21:43:46 +0000 |
| commit | b6ca597bd0d5eacd36e3c6204e96baa94a59c580 (patch) | |
| tree | cacdf876360b1356449b30146493bfa1b79cba20 /array.c | |
| parent | cf912b4421589ff5f6dcd678d4da788ed050efaf (diff) | |
* array.c (rb_ary_sample): Fix infinite loop bug [ruby-core:27075]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
| -rw-r--r-- | array.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -3367,8 +3367,8 @@ rb_ary_sample(argc, argv, 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) return rb_ary_shuffle(ary); result = rb_ary_new2(n); for (i=0; i<n; i++) { retry: |
