[前][次][番号順一覧][スレッド一覧]

ruby-changes:52443

From: nobu <ko1@a...>
Date: Fri, 7 Sep 2018 12:23:29 +0900 (JST)
Subject: [ruby-changes:52443] nobu:r64652 (trunk): ext/objspace/object_tracing.c (freeobj_i): no lookup before delete

nobu	2018-09-07 12:23:25 +0900 (Fri, 07 Sep 2018)

  New Revision: 64652

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64652

  Log:
    ext/objspace/object_tracing.c (freeobj_i): no lookup before delete

  Modified files:
    trunk/ext/objspace/object_tracing.c
Index: ext/objspace/object_tracing.c
===================================================================
--- ext/objspace/object_tracing.c	(revision 64651)
+++ ext/objspace/object_tracing.c	(revision 64652)
@@ -121,13 +121,14 @@ freeobj_i(VALUE tpval, void *data) https://github.com/ruby/ruby/blob/trunk/ext/objspace/object_tracing.c#L121
     st_data_t v;
     struct allocation_info *info;
 
-    if (st_lookup(arg->object_table, obj, &v)) {
-	info = (struct allocation_info *)v;
-	if (arg->keep_remains) {
+    if (arg->keep_remains) {
+	if (st_lookup(arg->object_table, obj, &v)) {
+	    info = (struct allocation_info *)v;
 	    info->living = 0;
 	}
-	else {
-	    st_delete(arg->object_table, &obj, &v);
+    }
+    else {
+	if (st_delete(arg->object_table, &obj, &v)) {
 	    delete_unique_str(arg->str_table, info->path);
 	    delete_unique_str(arg->str_table, info->class_path);
 	    ruby_xfree(info);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]