diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-17 02:58:28 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-17 02:58:28 +0000 |
commit | 78b4827b101788e71051f3c73afe8cfcbb113120 (patch) | |
tree | b05302de3b12562fc715e1293a10b5d957c31919 /string.c | |
parent | d2f1df77dd64e5eff5ebdea951abf3625a2a4f96 (diff) |
merge revision(s) 20354:
* 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_6@22364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -464,6 +464,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; @@ -474,6 +476,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; } @@ -532,7 +535,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; \ |