summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--string.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e5a73cd91..4cec74f6c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Nov 25 16:09:36 2008 Nobuyoshi Nakada <[email protected]>
+
+ * string.c (str_independent): no independent string points null_str.
+ [ruby-core:20082]
+
Tue Nov 25 03:37:42 2008 Hidetoshi NAGAI <[email protected]>
* ext/tk/lib/tkextlib/blt/tabset.rb,
diff --git a/string.c b/string.c
index 0c29fc9e6d..cdda09d275 100644
--- a/string.c
+++ b/string.c
@@ -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; \