aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-06-18 18:59:49 -0700
committerJeremy Evans <code@jeremyevans.net>2019-07-02 08:26:50 -0700
commit7582287eb27e6b649789ce31ffdcbbb9ffcaf726 (patch)
tree43faa29b74a1fba0426967becba6ed0564e98a64 /string.c
parenta4b5aaa9a7225693168e43455de2e10c3721b789 (diff)
downloadruby-7582287eb27e6b649789ce31ffdcbbb9ffcaf726.tar.gz
Make String#-@ not freeze receiver if called on unfrozen subclass instance
rb_fstring behavior in this case is to freeze the receiver. I'm not sure if that should be changed, so this takes the conservative approach of duping the receiver in String#-@ before passing to rb_fstring. Fixes [Bug #15926]
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);
}