summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/string.c b/string.c
index 99813c9694..44f78a6b34 100644
--- a/string.c
+++ b/string.c
@@ -1849,6 +1849,11 @@ static VALUE
rb_str_to_s(str)
VALUE str;
{
+ if (rb_obj_class(str) != rb_cString) {
+ VALUE dup = str_alloc(rb_cString);
+ rb_str_replace(dup, str);
+ return dup;
+ }
return str;
}