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

ruby-changes:43288

From: usa <ko1@a...>
Date: Fri, 10 Jun 2016 17:39:56 +0900 (JST)
Subject: [ruby-changes:43288] usa:r55362 (ruby_2_2): merge revision(s) 54934: [Backport #12355]

usa	2016-06-10 17:39:51 +0900 (Fri, 10 Jun 2016)

  New Revision: 55362

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55362

  Log:
    merge revision(s) 54934: [Backport #12355]
    
    * process.c (rb_exec_getargs): honor the expected argument types
      over the conversion method.  the basic language functionality
      should be robust.  [ruby-core:75388] [Bug #12355]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/process.c
    branches/ruby_2_2/test/ruby/test_process.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/process.c
===================================================================
--- ruby_2_2/process.c	(revision 55361)
+++ ruby_2_2/process.c	(revision 55362)
@@ -2012,12 +2012,24 @@ rb_check_argv(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/process.c#L2012
 }
 
 static VALUE
+check_hash(VALUE obj)
+{
+    if (SPECIAL_CONST_P(obj)) return Qnil;
+    switch (BUILTIN_TYPE(obj)) {
+      case T_STRING:
+      case T_ARRAY:
+	return Qnil;
+    }
+    return rb_check_hash_type(obj);
+}
+
+static VALUE
 rb_exec_getargs(int *argc_p, VALUE **argv_p, int accept_shell, VALUE *env_ret, VALUE *opthash_ret)
 {
     VALUE hash, prog;
 
     if (0 < *argc_p) {
-        hash = rb_check_hash_type((*argv_p)[*argc_p-1]);
+        hash = check_hash((*argv_p)[*argc_p-1]);
         if (!NIL_P(hash)) {
             *opthash_ret = hash;
             (*argc_p)--;
@@ -2025,7 +2037,7 @@ rb_exec_getargs(int *argc_p, VALUE **arg https://github.com/ruby/ruby/blob/trunk/ruby_2_2/process.c#L2037
     }
 
     if (0 < *argc_p) {
-        hash = rb_check_hash_type((*argv_p)[0]);
+        hash = check_hash((*argv_p)[0]);
         if (!NIL_P(hash)) {
             *env_ret = hash;
             (*argc_p)--;
Index: ruby_2_2/test/ruby/test_process.rb
===================================================================
--- ruby_2_2/test/ruby/test_process.rb	(revision 55361)
+++ ruby_2_2/test/ruby/test_process.rb	(revision 55362)
@@ -2041,4 +2041,22 @@ EOS https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_process.rb#L2041
     status = th.value
     assert status.success?, status.inspect
   end if defined?(fork)
+
+  def test_to_hash_on_arguments
+    all_assertions do |a|
+      %w[Array String].each do |type|
+        a.for(type) do
+          assert_separately(['-', EnvUtil.rubybin], <<-"END;")
+          class #{type}
+            def to_hash
+              raise "[Bug-12355]: #{type}#to_hash is called"
+            end
+          end
+          ex = ARGV[0]
+          assert_equal(true, system([ex, ex], "-e", ""))
+          END;
+        end
+      end
+    end
+  end
 end
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 55361)
+++ ruby_2_2/version.h	(revision 55362)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.6"
 #define RUBY_RELEASE_DATE "2016-06-10"
-#define RUBY_PATCHLEVEL 335
+#define RUBY_PATCHLEVEL 336
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 6
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 55361)
+++ ruby_2_2/ChangeLog	(revision 55362)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Fri Jun 10 17:34:09 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* process.c (rb_exec_getargs): honor the expected argument types
+	  over the conversion method.  the basic language functionality
+	  should be robust.  [ruby-core:75388] [Bug #12355]
+
 Fri Jun 10 16:30:16 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (new_if_gen): set newline flag to NODE_IF to trace all

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r54934


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

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