summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-14 04:46:22 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-14 04:46:22 +0000
commit43defa70006d957574578503365fef8d4d18c646 (patch)
treea72409ef2141abc2b0ed16b5da6533608e067499 /vm_insnhelper.c
parent68c6739e965cc5e7b0dd57d787a69126be45b865 (diff)
merge revision(s) 49499,49500,49501,49502,49504,49505,49506,49507: [Backport #10828]
* vm_insnhelper.c: Fix one type of symbol leak with +send+ * vm_insnhelper.c: Fix symbol leak with +send+ [Bug #10828] * vm_insnhelper.c (ci_missing_reason): return the reason of method missing in call info. * vm_insnhelper.c (vm_call_opt_send): re-apply r49500 with the proper missing reason. [Bug #10828] * vm_eval.c (send_internal), vm_insnhelper.c (vm_call_opt_send): convert String method name into a Symbol, as method_missing method expects its first argument to be a Symbol. [Bug #10828] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index f8939b6bf1..3fd3100d7c 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1499,6 +1499,19 @@ vm_call_bmethod(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
return vm_call_bmethod_body(th, ci, argv);
}
+static int
+ci_missing_reason(const rb_call_info_t *ci)
+{
+ int stat = 0;
+ if (ci->flag & VM_CALL_VCALL) {
+ stat |= NOEX_VCALL;
+ }
+ if (ci->flag & VM_CALL_SUPER) {
+ stat |= NOEX_SUPER;
+ }
+ return stat;
+}
+
static
#ifdef _MSC_VER
__forceinline
@@ -1528,24 +1541,24 @@ vm_call_opt_send(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *c
sym = TOPN(i);
- if (SYMBOL_P(sym)) {
- ci->mid = SYM2ID(sym);
- }
- else if (!(ci->mid = rb_check_id(&sym))) {
+ if (!(ci->mid = rb_check_id(&sym))) {
if (rb_method_basic_definition_p(CLASS_OF(ci->recv), idMethodMissing)) {
VALUE exc = make_no_method_exception(rb_eNoMethodError, NULL, ci->recv, rb_long2int(ci->argc), &TOPN(i));
rb_exc_raise(exc);
}
- ci->mid = rb_to_id(sym);
+ TOPN(i) = rb_str_intern(sym);
+ ci->mid = idMethodMissing;
+ th->method_missing_reason = ci->aux.missing_reason = ci_missing_reason(ci);
}
-
- /* shift arguments */
- if (i > 0) {
- MEMMOVE(&TOPN(i), &TOPN(i-1), VALUE, i);
+ else {
+ /* shift arguments */
+ if (i > 0) {
+ MEMMOVE(&TOPN(i), &TOPN(i-1), VALUE, i);
+ }
+ ci->argc -= 1;
+ DEC_SP(1);
}
ci->me = rb_method_entry_without_refinements(CLASS_OF(ci->recv), ci->mid, &ci->defined_class);
- ci->argc -= 1;
- DEC_SP(1);
ci->flag = VM_CALL_FCALL | VM_CALL_OPT_SEND;
@@ -1790,13 +1803,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
}
else {
/* method missing */
- int stat = 0;
- if (ci->flag & VM_CALL_VCALL) {
- stat |= NOEX_VCALL;
- }
- if (ci->flag & VM_CALL_SUPER) {
- stat |= NOEX_SUPER;
- }
+ const int stat = ci_missing_reason(ci);
if (ci->mid == idMethodMissing) {
rb_control_frame_t *reg_cfp = cfp;
VALUE *argv = STACK_ADDR_FROM_TOP(ci->argc);