diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-06 01:31:53 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-06 01:31:53 +0000 |
commit | b4f61ad610536eb8102c31b882dda44967ecd5a9 (patch) | |
tree | 2979c68c4428ddebfabc8c5cf656bfe35945ae6e /compile.c | |
parent | e27a538eab6a186be4d92147fd51d23eb4503abd (diff) | |
download | ruby-b4f61ad610536eb8102c31b882dda44967ecd5a9.tar.gz |
vm_core.h: fix symbols leak
* 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/trunk@49517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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; } } } |