diff --git a/ChangeLog b/ChangeLog index 8ae7f9e826..4560a6839c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun May 10 21:32:45 2015 Nobuyoshi Nakada + + * gc.c (gc_mark_children): call dmark function for non-NULL + pointers only, so that DATA_PTR can be NULL safely now. + Sun May 10 16:23:58 2015 Kazuki Tsujimoto * proc.c (proc_binding): fix segmentation fault on marking phase. diff --git a/gc.c b/gc.c index 46551f4558..3b2d5c9519 100644 --- a/gc.c +++ b/gc.c @@ -4300,12 +4300,14 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj) break; case T_DATA: - if (RTYPEDDATA_P(obj)) { - RUBY_DATA_FUNC mark_func = any->as.typeddata.type->function.dmark; - if (mark_func) (*mark_func)(DATA_PTR(obj)); - } - else { - if (any->as.data.dmark) (*any->as.data.dmark)(DATA_PTR(obj)); + { + void *const ptr = DATA_PTR(obj); + if (ptr) { + RUBY_DATA_FUNC mark_func = RTYPEDDATA_P(obj) ? + any->as.typeddata.type->function.dmark : + any->as.data.dmark; + if (mark_func) (*mark_func)(ptr); + } } break;