Skip to content

Commit

Permalink
Never call kind_of with klass=0
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Feb 24, 2022
1 parent 709a6a0 commit 764e4fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 1 addition & 8 deletions ext/objspace/objspace.c
Expand Up @@ -61,14 +61,7 @@ total_i(VALUE v, void *ptr)
{
struct total_data *data = (struct total_data *)ptr;

switch (BUILTIN_TYPE(v)) {
case T_NONE:
case T_IMEMO:
case T_ICLASS:
case T_NODE:
case T_ZOMBIE:
return;
default:
if (!rb_objspace_internal_object_p(v)) {
if (data->klass == 0 || rb_obj_is_kind_of(v, data->klass)) {
data->total += rb_obj_memsize_of(v);
}
Expand Down
2 changes: 2 additions & 0 deletions object.c
Expand Up @@ -791,6 +791,8 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
{
VALUE cl = CLASS_OF(obj);

RUBY_ASSERT(cl);

// Note: YJIT needs this function to never allocate and never raise when
// `c` is a class or a module.
c = class_or_module_required(c);
Expand Down

0 comments on commit 764e4fa

Please sign in to comment.