summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-10 12:32:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-10 12:32:47 +0000
commitf5299e93a7914e8ba588031a0603014c73a6c3fa (patch)
tree18173bd6ae2d030214452ba46212586952fb6d82
parent280d4c3733a27fee527a11004df45c1c255d03c8 (diff)
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--ChangeLog5
-rw-r--r--gc.c14
2 files changed, 13 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ae7f9e..4560a68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/gc.c b/gc.c
index 46551f4..3b2d5c9 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;