mrb_string_value_cstr() should not raise error for frozen strings

cf. http://qiita.com/tsahara@github/items/b2a442af95ac893e10a1 (Japanese).
parent 85bd9975
......@@ -2182,6 +2182,10 @@ mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr)
char *p = RSTR_PTR(ps);
if (!p || p[len] != '\0') {
if (RSTR_FROZEN_P(ps)) {
*ptr = str = mrb_str_dup(mrb, str);
ps = mrb_str_ptr(str);
}
mrb_str_modify(mrb, ps);
return RSTR_PTR(ps);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment