diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-25 07:09:39 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-25 07:09:39 +0000 |
commit | d5a75a355090971040f941e9c1cfaa7ea34c5513 (patch) | |
tree | 7fdf3db930c8b771627681c4b91ee2c0686de6c0 /string.c | |
parent | 264e35b5e0edcaa945a5cd9498d38cf040ba716c (diff) |
* string.c (str_independent): no independent string points null_str.
[ruby-core:20082]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -471,6 +471,8 @@ rb_str_format_m(str, arg) return rb_str_format(1, &arg, str); } +static const char null_str[] = ""; + static int str_independent(str) VALUE str; @@ -481,6 +483,7 @@ str_independent(str) if (OBJ_FROZEN(str)) rb_error_frozen("string"); if (!OBJ_TAINTED(str) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify string"); + if (RSTRING(str)->ptr == null_str) return 0; if (!FL_TEST(str, ELTS_SHARED)) return 1; return 0; } @@ -539,7 +542,6 @@ rb_str_associated(str) return Qfalse; } -static const char null_str[] = ""; #define make_null_str(s) do { \ FL_SET(s, ELTS_SHARED); \ RSTRING(s)->ptr = (char *)null_str; \ |