diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-10 12:32:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-10 12:32:47 +0000 |
commit | a5cd8e3fc60d52dfa3677ecdc5c51bc92ddde376 (patch) | |
tree | 18173bd6ae2d030214452ba46212586952fb6d82 | |
parent | 7fd2c810698a07aa57825e6c521b100da0bd2ce3 (diff) | |
download | ruby-a5cd8e3fc60d52dfa3677ecdc5c51bc92ddde376.tar.gz |
gc.c: never call dmark for NULL
* gc.c (gc_mark_children): call dmark function for non-NULL
pointers only, so that DATA_PTR can be NULL safely now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | gc.c | 14 |
2 files changed, 13 insertions, 6 deletions
@@ -1,3 +1,8 @@ +Sun May 10 21:32:45 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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 <kazuki@callcc.net> * proc.c (proc_binding): fix segmentation fault on marking phase. @@ -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; |