fix SEGV bug for mrb_str_new_static

mrb_str_new_static causes seg-fault when 3rd argument is negative.
This commit is contained in:
cubicdaiya
2014-02-28 02:07:09 +09:00
parent 25822f2430
commit 8336072e86
+3
View File
@@ -256,6 +256,9 @@ mrb_value
mrb_str_new_static(mrb_state *mrb, const char *p, size_t len)
{
struct RString *s;
if ((mrb_int)len < 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "negative string size (or size too big)");
}
s = mrb_obj_alloc_string(mrb);
s->len = len;