mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* 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
This commit is contained in:
parent
264e35b5e0
commit
d5a75a3550
2 changed files with 8 additions and 1 deletions
4
string.c
4
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; \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue