1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

marshal.c: check for prepended

* marshal.c (w_extended): check for prepended object.
  [ruby-core:53206] [Bug #8043]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-03-09 02:58:45 +00:00
parent b0c40fca24
commit b3265c0ed6
3 changed files with 17 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Sat Mar 9 11:58:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (w_extended): check for prepended object.
[ruby-core:53206] [Bug #8043]
Sat Mar 9 08:36:58 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (features_index_add_single, rb_feature_p): store single index

View file

@ -457,12 +457,17 @@ hash_each(VALUE key, VALUE value, struct dump_call_arg *arg)
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);

View file

@ -365,6 +365,11 @@ module MarshalTestLib
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