summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-17 02:58:28 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-17 02:58:28 +0000
commit387bbce71450a19f12dc1ac898b678c8ea5c6622 (patch)
treeb05302de3b12562fc715e1293a10b5d957c31919 /string.c
parentde8b764734f15b41698b4c9983b9bbb41216eef1 (diff)
downloadruby-387bbce71450a19f12dc1ac898b678c8ea5c6622.tar.gz
ruby-387bbce71450a19f12dc1ac898b678c8ea5c6622.tar.xz
ruby-387bbce71450a19f12dc1ac898b678c8ea5c6622.zip
merge revision(s) 20354:
* string.c (str_independent): no independent string points null_str. [ruby-core:20082] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6@22364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/string.c b/string.c
index 7e01712bb..d625c542a 100644
--- a/string.c
+++ b/string.c
@@ -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; \