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

ruby-changes:34645

From: nobu <ko1@a...>
Date: Mon, 7 Jul 2014 08:47:29 +0900 (JST)
Subject: [ruby-changes:34645] nobu:r46728 (trunk): string.c: do not use garbage object

nobu	2014-07-07 08:47:17 +0900 (Mon, 07 Jul 2014)

  New Revision: 46728

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

  Log:
    string.c: do not use garbage object
    
    * string.c (fstr_update_callback): should not access garbage
      object contents, copy from the argument instead.

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 46727)
+++ string.c	(revision 46728)
@@ -194,6 +194,7 @@ fstr_update_callback(st_data_t *key, st_ https://github.com/ruby/ruby/blob/trunk/string.c#L194
 	 * at next time */
 
 	if (rb_objspace_garbage_object_p(str)) {
+	    str = *fstr;
 	    goto create_new_fstr;
 	}
 
@@ -219,7 +220,6 @@ fstr_update_callback(st_data_t *key, st_ https://github.com/ruby/ruby/blob/trunk/string.c#L220
 VALUE
 rb_fstring(VALUE str)
 {
-    VALUE fstr = Qnil;
     Check_Type(str, T_STRING);
 
     if (!frozen_strings)
@@ -228,8 +228,8 @@ rb_fstring(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L228
     if (FL_TEST(str, RSTRING_FSTR))
 	return str;
 
-    st_update(frozen_strings, (st_data_t)str, fstr_update_callback, (st_data_t)&fstr);
-    return fstr;
+    st_update(frozen_strings, (st_data_t)str, fstr_update_callback, (st_data_t)&str);
+    return str;
 }
 
 static VALUE

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

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