зеркало из https://github.com/github/ruby.git
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:
Родитель
b0c40fca24
Коммит
b3265c0ed6
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче