mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
string.c: do not use garbage object
* string.c (fstr_update_callback): should not access garbage object contents, copy from the argument instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7ad35210a3
commit
69e9b27a28
1 changed files with 3 additions and 3 deletions
6
string.c
6
string.c
|
@ -194,6 +194,7 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existi
|
||||||
* at next time */
|
* at next time */
|
||||||
|
|
||||||
if (rb_objspace_garbage_object_p(str)) {
|
if (rb_objspace_garbage_object_p(str)) {
|
||||||
|
str = *fstr;
|
||||||
goto create_new_fstr;
|
goto create_new_fstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +220,6 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existi
|
||||||
VALUE
|
VALUE
|
||||||
rb_fstring(VALUE str)
|
rb_fstring(VALUE str)
|
||||||
{
|
{
|
||||||
VALUE fstr = Qnil;
|
|
||||||
Check_Type(str, T_STRING);
|
Check_Type(str, T_STRING);
|
||||||
|
|
||||||
if (!frozen_strings)
|
if (!frozen_strings)
|
||||||
|
@ -228,8 +228,8 @@ rb_fstring(VALUE str)
|
||||||
if (FL_TEST(str, RSTRING_FSTR))
|
if (FL_TEST(str, RSTRING_FSTR))
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
st_update(frozen_strings, (st_data_t)str, fstr_update_callback, (st_data_t)&fstr);
|
st_update(frozen_strings, (st_data_t)str, fstr_update_callback, (st_data_t)&str);
|
||||||
return fstr;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Reference in a new issue