diff options
-rw-r--r-- | class.c | 4 | ||||
-rw-r--r-- | include/ruby/ruby.h | 2 |
2 files changed, 3 insertions, 3 deletions
@@ -1584,8 +1584,8 @@ rb_freeze_singleton_class(VALUE x) /* should not propagate to meta-meta-class, and so on */ if (!(RBASIC(x)->flags & FL_SINGLETON)) { VALUE klass = RBASIC_CLASS(x); - klass = RCLASS_ORIGIN(klass); - if (FL_TEST(klass, (FL_SINGLETON|FL_FREEZE)) == FL_SINGLETON) { + if (klass && (klass = RCLASS_ORIGIN(klass)) != 0 && + FL_TEST(klass, (FL_SINGLETON|FL_FREEZE)) == FL_SINGLETON) { OBJ_FREEZE_RAW(klass); } } diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 3d6e45bc4f..6a3949ab8e 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1122,7 +1122,7 @@ rb_obj_freeze_inline(VALUE x) { if (FL_ABLE(x)) { OBJ_FREEZE_RAW(x); - if (!(RBASIC(x)->flags & FL_SINGLETON)) { + if (RBASIC_CLASS(x) && !(RBASIC(x)->flags & FL_SINGLETON)) { rb_freeze_singleton_class(x); } } |