diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | string.c | 4 |
2 files changed, 8 insertions, 1 deletions
@@ -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, @@ -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; \ |