mrb_string_value_cstr() should not raise error for frozen strings

cf. http://qiita.com/tsahara@github/items/b2a442af95ac893e10a1 (Japanese).
This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-12-01 10:45:43 +09:00
parent 85bd99757c
commit 05411ee15e
+4
View File
@@ -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);
}