diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-29 14:53:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-29 14:53:51 +0000 |
commit | d93746490d15deb4bdf35a47348106a41338002c (patch) | |
tree | ebc1a373112bee0625020580bcb3719c32d6b0bb /array.c | |
parent | 0d6329343aaa02234b89af0ae2a3129470bda760 (diff) |
* array.c (rb_ary_set_len): new function to set array length.
* vm_eval.c (method_missing): set the length of argv array, to mark
arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -1310,6 +1310,21 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl) } } +void +rb_ary_set_len(VALUE ary, long len) +{ + long capa; + + rb_ary_modify_check(ary); + if (ARY_SHARED_P(ary)) { + rb_raise(rb_eRuntimeError, "can't set length of shared "); + } + if (len > (capa = (long)ARY_CAPA(ary))) { + rb_bug("probable buffer overflow: %ld for %ld", len, capa); + } + ARY_SET_LEN(ary, len); +} + /*! * expands or shrinks \a ary to \a len elements. * expanded region will be filled with Qnil. |