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

ruby-changes:43327

From: nagachika <ko1@a...>
Date: Tue, 14 Jun 2016 03:23:51 +0900 (JST)
Subject: [ruby-changes:43327] nagachika:r55401 (ruby_2_3): merge revision(s) 54934: [Backport #12355]

nagachika	2016-06-14 03:23:45 +0900 (Tue, 14 Jun 2016)

  New Revision: 55401

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

  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_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/process.c
    branches/ruby_2_3/test/ruby/test_process.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/process.c
===================================================================
--- ruby_2_3/process.c	(revision 55400)
+++ ruby_2_3/process.c	(revision 55401)
@@ -1987,12 +1987,24 @@ rb_check_argv(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/process.c#L1987
 }
 
 static VALUE
+check_hash(VALUE obj)
+{
+    if (RB_SPECIAL_CONST_P(obj)) return Qnil;
+    switch (RB_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)--;
@@ -2000,7 +2012,7 @@ rb_exec_getargs(int *argc_p, VALUE **arg https://github.com/ruby/ruby/blob/trunk/ruby_2_3/process.c#L2012
     }
 
     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_3/test/ruby/test_process.rb
===================================================================
--- ruby_2_3/test/ruby/test_process.rb	(revision 55400)
+++ ruby_2_3/test/ruby/test_process.rb	(revision 55401)
@@ -2256,4 +2256,22 @@ EOS https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_process.rb#L2256
       system(bin, "--disable=gems", "-w", "-e", "puts ARGV", *args)
     end;
   end
+
+  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_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 55400)
+++ ruby_2_3/version.h	(revision 55401)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.2"
 #define RUBY_RELEASE_DATE "2016-06-14"
-#define RUBY_PATCHLEVEL 125
+#define RUBY_PATCHLEVEL 126
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 6
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 55400)
+++ ruby_2_3/ChangeLog	(revision 55401)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Tue Jun 14 03:15:54 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]
+
 Tue Jun 14 03:02:38 2016  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c, include/ruby/win32.h (rb_w32_utruncate): implements new

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


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

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