Commit fe057faf authored by Masaki Muranaka's avatar Masaki Muranaka

Add the type check in mrb_str_to_cstr().

parent c9f3fd47
......@@ -262,6 +262,10 @@ mrb_str_to_cstr(mrb_state *mrb, mrb_value str0)
{
mrb_value str;
if (!mrb_string_p(str0)) {
mrb_raise(mrb, E_TYPE_ERROR, "expected String");
}
str = mrb_str_new(mrb, RSTRING_PTR(str0), RSTRING_LEN(str0));
if (strlen(RSTRING_PTR(str)) != RSTRING_LEN(str)) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string contains null byte");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment