aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/string.c b/string.c
index 3935eb426e..59b81b44e6 100644
--- a/string.c
+++ b/string.c
@@ -119,6 +119,9 @@ str_alloc(VALUE klass)
NEWOBJ(str, struct RString);
OBJSETUP(str, klass, T_STRING);
+ if (klass == rb_cSymbol) {
+ RBASIC(str)->klass = rb_cString;
+ }
str->as.heap.ptr = 0;
str->as.heap.len = 0;
str->as.heap.aux.capa = 0;
@@ -135,7 +138,6 @@ str_new(VALUE klass, const char *ptr, long len)
rb_raise(rb_eArgError, "negative string size (or size too big)");
}
- if (klass == rb_cSymbol) klass = rb_cString;
str = str_alloc(klass);
if (len > RSTRING_EMBED_LEN_MAX) {
RSTRING(str)->as.heap.aux.capa = len;