ruby-changes:40900
From: nobu <ko1@a...>
Date: Wed, 9 Dec 2015 02:28:42 +0900 (JST)
Subject: [ruby-changes:40900] nobu:r52979 (trunk): gc.c: NULL check at memsize
nobu 2015-12-09 02:28:32 +0900 (Wed, 09 Dec 2015) New Revision: 52979 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52979 Log: 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. Modified files: trunk/gc.c Index: gc.c =================================================================== --- gc.c (revision 52978) +++ gc.c (revision 52979) @@ -1953,12 +1953,14 @@ rb_data_typed_object_zalloc(VALUE klass, https://github.com/ruby/ruby/blob/trunk/gc.c#L1953 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 * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/