summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-09 02:58:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-09 02:58:45 +0000
commitb3265c0ed6d7a2db76c172aef128445902c36c63 (patch)
treebb77d7444b5db7b2119a90691cf38e03e4ce0bdf /marshal.c
parentb0c40fca240dec15e8d709f14115d94ef6766c1b (diff)
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
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/marshal.c b/marshal.c
index 7b45d1c835..9ec1f9400f 100644
--- a/marshal.c
+++ b/marshal.c
@@ -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);