diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-12-01 10:45:43 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-12-01 10:45:43 +0900 |
| commit | 05411ee15e13d415fa385c534b155452668d052b (patch) | |
| tree | 07b810f676b7da9a018f6c9ba1b60dd13d1469b1 /src/string.c | |
| parent | 85bd99757cd80936ee47f2738aedcf1723190ed1 (diff) | |
| download | mruby-05411ee15e13d415fa385c534b155452668d052b.tar.gz mruby-05411ee15e13d415fa385c534b155452668d052b.zip | |
mrb_string_value_cstr() should not raise error for frozen strings
cf. http://qiita.com/tsahara@github/items/b2a442af95ac893e10a1 (Japanese).
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); } |
