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

ruby-changes:38586

From: usa <ko1@a...>
Date: Fri, 29 May 2015 13:43:41 +0900 (JST)
Subject: [ruby-changes:38586] usa:r50667 (ruby_2_1): * marshal.c (r_symreal): register the symbol name first so that

usa	2015-05-29 13:43:10 +0900 (Fri, 29 May 2015)

  New Revision: 50667

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

  Log:
    * marshal.c (r_symreal): register the symbol name first so that
      r_symlink always returns valid names. [Bug #10991]

  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/marshal.c
    branches/ruby_2_1/test/ruby/test_marshal.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 50666)
+++ ruby_2_1/ChangeLog	(revision 50667)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Fri May 29 13:41:44 2015  NAKAMURA Usaku  <usa@r...>
+
+	* marshal.c (r_symreal): register the symbol name first so that
+	  r_symlink always returns valid names. [Bug #10991]
+
 Thu May 28 09:51:28 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* hash.c (rb_any_hash): use same hash values with Float#hash so
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 50666)
+++ ruby_2_1/version.h	(revision 50667)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.7"
-#define RUBY_RELEASE_DATE "2015-05-28"
-#define RUBY_PATCHLEVEL 358
+#define RUBY_RELEASE_DATE "2015-05-29"
+#define RUBY_PATCHLEVEL 359
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 28
+#define RUBY_RELEASE_DAY 29
 
 #include "ruby/version.h"
 
Index: ruby_2_1/marshal.c
===================================================================
--- ruby_2_1/marshal.c	(revision 50666)
+++ ruby_2_1/marshal.c	(revision 50667)
@@ -1272,7 +1272,9 @@ r_symreal(struct load_arg *arg, int ivar https://github.com/ruby/ruby/blob/trunk/ruby_2_1/marshal.c#L1272
     int idx = -1;
     st_index_t n = arg->symbols->num_entries;
 
-    st_insert(arg->symbols, (st_data_t)n, (st_data_t)0);
+    if (rb_enc_str_asciionly_p(s)) rb_enc_associate_index(s, ENCINDEX_US_ASCII);
+    id = rb_intern_str(s);
+    st_insert(arg->symbols, (st_data_t)n, (st_data_t)id);
     if (ivar) {
 	long num = r_long(arg);
 	while (num-- > 0) {
@@ -1282,7 +1284,6 @@ r_symreal(struct load_arg *arg, int ivar https://github.com/ruby/ruby/blob/trunk/ruby_2_1/marshal.c#L1284
     }
     if (idx > 0) rb_enc_associate_index(s, idx);
     id = rb_intern_str(s);
-    st_insert(arg->symbols, (st_data_t)n, (st_data_t)id);
 
     return id;
 }
Index: ruby_2_1/test/ruby/test_marshal.rb
===================================================================
--- ruby_2_1/test/ruby/test_marshal.rb	(revision 50666)
+++ ruby_2_1/test/ruby/test_marshal.rb	(revision 50667)
@@ -246,6 +246,17 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_marshal.rb#L246
     assert_equal(ary, Marshal.load(Marshal.dump(ary)), bug2548)
   end
 
+  def test_symlink_in_ivar
+    bug10991 = '[ruby-core:68587] [Bug #10991]'
+    sym = Marshal.load("\x04\x08" +
+                       "I" ":\x0bKernel" +
+                       ("\x06" +
+                        ("I" ":\x07@a" +
+                         ("\x06" ":\x07@b" "e;\x0""o:\x0bObject""\x0")) +
+                        "0"))
+    assert_equal(:Kernel, sym, bug10991)
+  end
+
   ClassUTF8 = eval("class R\u{e9}sum\u{e9}; self; end")
 
   iso_8859_1 = Encoding::ISO_8859_1

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

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