Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* 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
  • Loading branch information...
commit d93746490d15deb4bdf35a47348106a41338002c 1 parent 0d63293
@nobu nobu authored
Showing with 23 additions and 1 deletion.
  1. +6 −1 ChangeLog
  2. +15 −0 array.c
  3. +1 −0  internal.h
  4. +1 −0  vm_eval.c
View
7 ChangeLog
@@ -1,4 +1,9 @@
-Fri Jul 29 23:53:44 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jul 29 23:53:48 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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.
* vm_eval.c (rb_apply): get rid of too large alloca.
View
15 array.c
@@ -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.
View
1  internal.h
@@ -41,6 +41,7 @@ struct vtm; /* defined by timev.h */
/* array.c */
VALUE rb_ary_last(int, VALUE *, VALUE);
+void rb_ary_set_len(VALUE, long);
/* bignum.c */
VALUE rb_big_fdiv(VALUE x, VALUE y);
View
1  vm_eval.c
@@ -568,6 +568,7 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status)
}
nargv[0] = ID2SYM(id);
MEMCPY(nargv + 1, argv, VALUE, argc);
+ if (argv_ary) rb_ary_set_len(argv_ary, argc + 1);
if (rb_method_basic_definition_p(CLASS_OF(obj) , idMethodMissing)) {
raise_method_missing(th, argc+1, nargv, obj, call_status | NOEX_MISSING);
Please sign in to comment.
Something went wrong with that request. Please try again.