diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-29 04:43:10 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-29 04:43:10 +0000 |
commit | 847b7bcfb3db371acb552200913e5302c3759796 (patch) | |
tree | 45bb640145b58048241889940beb54d2cb6b3d1a | |
parent | ed737b87d46521e5bf082138f251eb3018966821 (diff) |
* marshal.c (r_symreal): register the symbol name first so that
r_symlink always returns valid names. [Bug #10991]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | marshal.c | 5 | ||||
-rw-r--r-- | test/ruby/test_marshal.rb | 11 | ||||
-rw-r--r-- | version.h | 6 |
4 files changed, 22 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Fri May 29 13:41:44 2015 NAKAMURA Usaku <usa@ruby-lang.org> + + * 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@ruby-lang.org> * hash.c (rb_any_hash): use same hash values with Float#hash so @@ -1272,7 +1272,9 @@ r_symreal(struct load_arg *arg, int ivar) 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) } 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; } diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 126efc8ae6..967aa37723 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -246,6 +246,17 @@ class TestMarshal < Test::Unit::TestCase 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 @@ -1,10 +1,10 @@ #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" |