ruby-changes:14068
From: nobu <ko1@a...>
Date: Sat, 21 Nov 2009 16:39:10 +0900 (JST)
Subject: [ruby-changes:14068] Ruby:r25881 (trunk): * marshal.c (marshal_dump): use normal object as the buffer so
nobu 2009-11-21 16:38:51 +0900 (Sat, 21 Nov 2009) New Revision: 25881 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25881 Log: * marshal.c (marshal_dump): use normal object as the buffer so that no hidden object is exposed to ruby-level. [ruby-dev:39744] Modified files: trunk/ChangeLog trunk/marshal.c trunk/test/ruby/test_marshal.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 25880) +++ ChangeLog (revision 25881) @@ -1,3 +1,8 @@ +Sat Nov 21 16:38:50 2009 Nobuyoshi Nakada <nobu@r...> + + * marshal.c (marshal_dump): use normal object as the buffer so + that no hidden object is exposed to ruby-level. [ruby-dev:39744] + Sat Nov 21 15:58:43 2009 NARUSE, Yui <naruse@r...> * io.c (read_all): fix: false negative invalid byte seequence Index: marshal.c =================================================================== --- marshal.c (revision 25880) +++ marshal.c (revision 25881) @@ -925,7 +925,7 @@ arg->untrust = FALSE; arg->compat_tbl = st_init_numtable(); arg->encodings = 0; - arg->str = rb_str_tmp_new(0); + arg->str = rb_str_buf_new(0); if (!NIL_P(port)) { if (!rb_respond_to(port, s_write)) { type_error: @@ -949,7 +949,6 @@ rb_io_write(arg->dest, arg->str); rb_str_resize(arg->str, 0); } - RBASIC(arg->str)->klass = rb_cString; clear_dump_arg(arg); RB_GC_GUARD(wrapper); Index: test/ruby/test_marshal.rb =================================================================== --- test/ruby/test_marshal.rb (revision 25880) +++ test/ruby/test_marshal.rb (revision 25881) @@ -300,4 +300,14 @@ assert(true, '[ruby-dev:39425]') assert_raise(StopIteration) {e.next} end + + def test_dump_buffer + bug2390 = '[ruby-dev:39744]' + w = "" + def w.write(str) + self << str.to_s + end + Marshal.dump(Object.new, w) + assert_not_empty(w, bug2390) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/