summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/string.c b/string.c
index 6bb8a24313..2bf9586e98 100644
--- a/string.c
+++ b/string.c
@@ -2658,6 +2658,9 @@ str_uplus(VALUE str)
static VALUE
str_uminus(VALUE str)
{
+ if (!BARE_STRING_P(str) && !rb_obj_frozen_p(str)) {
+ str = rb_str_dup(str);
+ }
return rb_fstring(str);
}