* gc.c (rb_objspace_data_type_memsize): consider NULL data uses no
  memory without calling dsize function as well as other functions.
  fix SEGV in test/objspace with RUBY_ISEQ_DUMP_DEBUG=to_binary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-12-08 17:28:32 +00:00
Родитель e78bf7976c
Коммит a8fb40db8c
1 изменённых файлов: 7 добавлений и 5 удалений

12
gc.c
Просмотреть файл

@ -1953,12 +1953,14 @@ rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type
size_t
rb_objspace_data_type_memsize(VALUE obj)
{
if (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj)->function.dsize) {
return RTYPEDDATA_TYPE(obj)->function.dsize(RTYPEDDATA_DATA(obj));
}
else {
return 0;
if (RTYPEDDATA_P(obj)) {
const rb_data_type_t *type = RTYPEDDATA_TYPE(obj);
const void *ptr = RTYPEDDATA_DATA(obj);
if (ptr && type->function.dsize) {
return type->function.dsize(ptr);
}
}
return 0;
}
const char *