gc.c: NULL check at memsize
* 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:
parent
e78bf7976c
commit
a8fb40db8c
10
gc.c
10
gc.c
@ -1953,12 +1953,14 @@ rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type
|
|||||||
size_t
|
size_t
|
||||||
rb_objspace_data_type_memsize(VALUE obj)
|
rb_objspace_data_type_memsize(VALUE obj)
|
||||||
{
|
{
|
||||||
if (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj)->function.dsize) {
|
if (RTYPEDDATA_P(obj)) {
|
||||||
return RTYPEDDATA_TYPE(obj)->function.dsize(RTYPEDDATA_DATA(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user