From 05411ee15e13d415fa385c534b155452668d052b Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 1 Dec 2015 10:45:43 +0900 Subject: mrb_string_value_cstr() should not raise error for frozen strings cf. http://qiita.com/tsahara@github/items/b2a442af95ac893e10a1 (Japanese). --- src/string.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/string.c') diff --git a/src/string.c b/src/string.c index 7983a925e..2b47b06ca 100644 --- a/src/string.c +++ b/src/string.c @@ -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); } -- cgit v1.2.3