mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user