Project

General

Profile

Actions

Bug #12011

closed

honor Marshal.load post proc value for TYPE_LINK

Added by naruse (Yui NARUSE) about 8 years ago. Updated almost 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:72955]

Description

Following test doesn't work.
A patch also attached.
Both of them are worked by nahi.

diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index 482637f..262e7f6 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -712,4 +712,10 @@ def test_no_internal_ids
     assert_predicate(status, :success?)
     assert_equal(expected, out)
   end
+
+  def test_marshal_post_proc
+    str = 'x' # for link
+    obj = [str, str]
+    assert_equal(['X', 'X'], Marshal.load(Marshal.dump(obj), ->(v) { v == str ? v.upcase : v }))
+  end
 end
diff --git a/marshal.c b/marshal.c
index d67ce87..d64e5ff 100644
--- a/marshal.c
+++ b/marshal.c
@@ -1569,7 +1569,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
 	    rb_raise(rb_eArgError, "dump format error (unlinked)");
 	}
 	v = (VALUE)link;
-	r_post_proc(v, arg);
+	v = r_post_proc(v, arg);
 	break;
 
       case TYPE_IVAR:

https://github.com/ruby/ruby/pull/1204

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0