From 95f54fb01969fe2799dc6425bbd4102f334feada Mon Sep 17 00:00:00 2001 From: glass Date: Tue, 12 May 2015 13:24:53 +0000 Subject: * enum.c (enum_to_a): fix incompatibility introduced in r50457. [Bug #11130] * test/ruby/test_enum.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enum.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'enum.c') diff --git a/enum.c b/enum.c index ea151b4..2516934 100644 --- a/enum.c +++ b/enum.c @@ -517,11 +517,11 @@ enum_to_a(int argc, VALUE *argv, VALUE obj) { VALUE ary, size = rb_check_funcall(obj, id_size, 0, 0); - if (NIL_P(size) || size == Qundef) { - ary = rb_ary_new(); + if (FIXNUM_P(size)) { + ary = rb_ary_new_capa(NUM2LONG(size)); } else { - ary = rb_ary_new_capa(NUM2LONG(size)); + ary = rb_ary_new(); } rb_block_call(obj, id_each, argc, argv, collect_all, ary); -- cgit v1.1