diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-05 03:13:32 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-05 03:13:32 +0000 |
commit | cf44d9fcbc69014f2679d0333e95dd94af3e6777 (patch) | |
tree | 69a927a646cda337060399a2a8c3b08976f3bdcb /array.c | |
parent | 782fe4e3a8bead0d26b8cbb46fc2af88a7329845 (diff) | |
download | ruby-cf44d9fcbc69014f2679d0333e95dd94af3e6777.tar.gz ruby-cf44d9fcbc69014f2679d0333e95dd94af3e6777.tar.xz ruby-cf44d9fcbc69014f2679d0333e95dd94af3e6777.zip |
* array.c (rb_ary_slice_bang): should adjust length before making
sub-array.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -1794,6 +1794,9 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary) pos = RARRAY_LEN(ary) + pos; if (pos < 0) return Qnil; } + if (RARRAY_LEN(ary) < len || RARRAY_LEN(ary) < pos + len) { + len = RARRAY_LEN(ary) - pos; + } arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos); RBASIC(arg2)->klass = rb_obj_class(ary); rb_ary_splice(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */ |