Skip to content

Commit

Permalink
mrb_string_value_cstr() should not raise error for frozen strings
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 1, 2015
1 parent 85bd997 commit 05411ee
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 05411ee

Please sign in to comment.