diff options
author | Koichi Sasada <[email protected]> | 2020-12-01 16:34:59 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2020-12-01 18:16:23 +0900 |
commit | 764de7566ffa3fe828abf13ec93d76515ba27dd1 (patch) | |
tree | 3611b0c03eedc8fad41a7783860cdb04e9c67355 /string.c | |
parent | d5e16161f6871793bf2f148b5a6901a1a3f6d326 (diff) |
should not use rb_str_modify(), too
Same as 8247b8edde, should not use rb_str_modify() here.
https://bugs.ruby-lang.org/issues/17343#change-88858
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3833
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -214,6 +214,16 @@ str_make_independent(VALUE str) str_make_independent_expand((str), len, 0L, termlen); } +static inline int str_dependent_p(VALUE str); + +void +rb_str_make_independent(VALUE str) +{ + if (str_dependent_p(str)) { + str_make_independent(str); + } +} + /* symbols for [up|down|swap]case/capitalize options */ static VALUE sym_ascii, sym_turkic, sym_lithuanian, sym_fold; @@ -324,7 +334,7 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t data, int exist str = str_new_frozen(rb_cString, str); if (STR_SHARED_P(str)) { /* str should not be shared */ /* shared substring */ - str_make_independent(str); + str_make_independent(str); assert(OBJ_FROZEN(str)); } if (!BARE_STRING_P(str)) { |