ruby-changes:27598
From: nobu <ko1@a...>
Date: Sat, 9 Mar 2013 11:58:54 +0900 (JST)
Subject: [ruby-changes:27598] nobu:r39650 (trunk): marshal.c: check for prepended
nobu 2013-03-09 11:58:45 +0900 (Sat, 09 Mar 2013) New Revision: 39650 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39650 Log: marshal.c: check for prepended * marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043] Modified files: trunk/ChangeLog trunk/marshal.c trunk/test/ruby/marshaltestlib.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39649) +++ ChangeLog (revision 39650) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Mar 9 11:58:39 2013 Nobuyoshi Nakada <nobu@r...> + + * marshal.c (w_extended): check for prepended object. + [ruby-core:53206] [Bug #8043] + Sat Mar 9 08:36:58 2013 Nobuyoshi Nakada <nobu@r...> * load.c (features_index_add_single, rb_feature_p): store single index Index: marshal.c =================================================================== --- marshal.c (revision 39649) +++ marshal.c (revision 39650) @@ -457,12 +457,17 @@ hash_each(VALUE key, VALUE value, struct https://github.com/ruby/ruby/blob/trunk/marshal.c#L457 return ST_CONTINUE; } +#define SINGLETON_DUMP_UNABLE_P(klass) \ + (RCLASS_M_TBL(klass)->num_entries || \ + (RCLASS_IV_TBL(klass) && RCLASS_IV_TBL(klass)->num_entries > 1)) + static void w_extended(VALUE klass, struct dump_arg *arg, int check) { if (check && FL_TEST(klass, FL_SINGLETON)) { - if (RCLASS_M_TBL(klass)->num_entries || - (RCLASS_IV_TBL(klass) && RCLASS_IV_TBL(klass)->num_entries > 1)) { + VALUE origin = RCLASS_ORIGIN(klass); + if (SINGLETON_DUMP_UNABLE_P(klass) || + (origin != klass && SINGLETON_DUMP_UNABLE_P(origin))) { rb_raise(rb_eTypeError, "singleton can't be dumped"); } klass = RCLASS_SUPER(klass); Index: test/ruby/marshaltestlib.rb =================================================================== --- test/ruby/marshaltestlib.rb (revision 39649) +++ test/ruby/marshaltestlib.rb (revision 39650) @@ -365,6 +365,11 @@ module MarshalTestLib https://github.com/ruby/ruby/blob/trunk/test/ruby/marshaltestlib.rb#L365 o = Object.new def o.m() end assert_raise(TypeError) { marshaltest(o) } + + bug8043 = '[ruby-core:53206] [Bug #8043]' + class << o; prepend Mod1; end + assert_raise(TypeError, bug8043) {marshaltest(o)} + o = Object.new c = class << o @v = 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/