merge revision(s) 49517: [Backport #10831]

* vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols
	  list to get rid of inadvertent creation by variable keyword
	  arguments.  [ruby-core:68031] [Bug #10831]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2015-02-20 08:52:15 +00:00
parent e896f10487
commit 81c3784004
6 changed files with 49 additions and 19 deletions

View file

@ -2409,7 +2409,7 @@ compile_array_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE * const
{
int len = (int)node->nd_alen / 2;
rb_call_info_kw_arg_t *kw_arg = (rb_call_info_kw_arg_t *)ruby_xmalloc(sizeof(rb_call_info_kw_arg_t) + sizeof(VALUE) * (len - 1));
ID *keywords = kw_arg->keywords;
VALUE *keywords = kw_arg->keywords;
int i = 0;
kw_arg->keyword_len = len;
@ -2418,7 +2418,7 @@ compile_array_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE * const
for (i=0; node != NULL; i++, node = node->nd_next->nd_next) {
NODE *key_node = node->nd_head;
NODE *val_node = node->nd_next->nd_head;
keywords[i] = SYM2ID(key_node->nd_lit);
keywords[i] = key_node->nd_lit;
COMPILE(ret, "keyword values", val_node);
}
assert(i == len);
@ -5844,12 +5844,14 @@ iseq_build_callinfo_from_hash(rb_iseq_t *iseq, VALUE op)
if (!NIL_P(vkw_arg)) {
int i;
int len = RARRAY_LENINT(vkw_arg);
size_t n = sizeof(rb_call_info_kw_arg_t) + sizeof(ID) * (len - 1);
size_t n = sizeof(rb_call_info_kw_arg_t) + sizeof(VALUE) * (len - 1);
kw_arg = xmalloc(n);
kw_arg->keyword_len = len;
for (i = 0; i < len; i++) {
kw_arg->keywords[i] = SYM2ID(RARRAY_AREF(vkw_arg, i));
VALUE kw = RARRAY_AREF(vkw_arg, i);
SYM2ID(kw); /* make immortal */
kw_arg->keywords[i] = kw;
}
}
}