[前][次][番号順一覧][スレッド一覧]

ruby-changes:31834

From: sorah <ko1@a...>
Date: Fri, 29 Nov 2013 17:57:12 +0900 (JST)
Subject: [ruby-changes:31834] sorah:r43913 (trunk): * vm_insnhelper.c (check_match): Fix SEGV with VM_CHECKMATCH_TYPE_CASE

sorah	2013-11-29 17:57:02 +0900 (Fri, 29 Nov 2013)

  New Revision: 43913

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43913

  Log:
    * vm_insnhelper.c (check_match): Fix SEGV with VM_CHECKMATCH_TYPE_CASE
      and class of `pattern` has `method_missing`
      [Bug #8882] [ruby-core:58606]

  Modified files:
    trunk/ChangeLog
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43912)
+++ ChangeLog	(revision 43913)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov 29 17:53:22 2013  Shota Fukumori  <her@s...>
+
+	* vm_insnhelper.c (check_match): Fix SEGV with VM_CHECKMATCH_TYPE_CASE
+	  and class of `pattern` has `method_missing`
+	  [Bug #8882] [ruby-core:58606]
+
 Fri Nov 29 17:06:09 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm_eval.c (rb_yield_block): yield block with rb_block_call_func
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 43912)
+++ vm_insnhelper.c	(revision 43913)
@@ -947,7 +947,13 @@ check_match(VALUE pattern, VALUE target, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L947
       case VM_CHECKMATCH_TYPE_CASE: {
 	VALUE defined_class;
 	rb_method_entry_t *me = rb_method_entry_with_refinements(CLASS_OF(pattern), idEqq, &defined_class);
-	return vm_call0(GET_THREAD(), pattern, idEqq, 1, &target, me, defined_class);
+	if (me) {
+	  return vm_call0(GET_THREAD(), pattern, idEqq, 1, &target, me, defined_class);
+	}
+	else {
+	  /* fallback to funcall (e.g. method_missing) */
+	  return rb_funcall2(pattern, idEqq, 1, &target);
+	}
       }
       default:
 	rb_bug("check_match: unreachable");

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]