summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-29 03:28:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-29 03:28:43 +0000
commit360a8652464c4fd44808d488a0f178272b98208a (patch)
treed26cd33fbce9b2427c4083e5b4b9740b329fa030
parentfbc3f55ba7f67ed2198f04d9c4ed221cf18e4162 (diff)
marshal.c: fix symlink index
* marshal.c (w_symbol): fix symlink index. register the given symbols, not its name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--marshal.c3
-rw-r--r--test/ruby/test_marshal.rb4
2 files changed, 6 insertions, 1 deletions
diff --git a/marshal.c b/marshal.c
index b14635f034c..598f90f1874 100644
--- a/marshal.c
+++ b/marshal.c
@@ -422,6 +422,7 @@ w_symbol(VALUE sym, struct dump_arg *arg)
w_long((long)num, arg);
}
else {
+ const VALUE orig_sym = sym;
sym = rb_sym2str(sym);
if (!sym) {
rb_raise(rb_eTypeError, "can't dump anonymous ID %"PRIdVALUE, sym);
@@ -436,7 +437,7 @@ w_symbol(VALUE sym, struct dump_arg *arg)
}
w_byte(TYPE_SYMBOL, arg);
w_bytes(RSTRING_PTR(sym), RSTRING_LEN(sym), arg);
- st_add_direct(arg->symbols, sym, arg->symbols->num_entries);
+ st_add_direct(arg->symbols, orig_sym, arg->symbols->num_entries);
if (!NIL_P(encname)) {
struct dump_call_arg c_arg;
c_arg.limit = 1;
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index 0b7a121185e..9b82d52233e 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -248,6 +248,10 @@ class TestMarshal < Test::Unit::TestCase
assert_equal(ary, Marshal.load(Marshal.dump(ary)), bug2548)
end
+ def test_symlink
+ assert_include(Marshal.dump([:a, :a]), ';')
+ end
+
ClassUTF8 = eval("class R\u{e9}sum\u{e9}; self; end")
iso_8859_1 = Encoding::ISO_8859_1