From d04f1089528f395caf7398a94af947f7e32128e2 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 10 Dec 2007 12:01:45 +0000 Subject: * array.c (rb_ary_slice_bang): should return nil if position out of range. a patch from Akinori MUSHA . [ruby-dev:32518] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 1 + 1 file changed, 1 insertion(+) (limited to 'array.c') diff --git a/array.c b/array.c index 4eaf0c7ddc..30caf7b5da 100644 --- a/array.c +++ b/array.c @@ -1888,6 +1888,7 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary) delete_pos_len: if (pos < 0) { pos = RARRAY_LEN(ary) + pos; + if (pos < 0) return Qnil; } arg2 = rb_ary_subseq(ary, pos, len); rb_ary_splice(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */ -- cgit v1.2.3