Commit f792552a authored by Carson McDonald's avatar Carson McDonald

Add null check after mrb_realloc for array

parent 6d0e2519
......@@ -192,8 +192,14 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
if (capa > ARY_MAX_SIZE) capa = ARY_MAX_SIZE; /* len <= capa <= ARY_MAX_SIZE */
if (capa > a->aux.capa) {
mrb_value *expanded_ptr = (mrb_value *)mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*capa);
if(!expanded_ptr) {
mrb_raise(mrb, E_RUNTIME_ERROR, "out of memory");
}
a->aux.capa = capa;
a->ptr = (mrb_value *)mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*capa);
a->ptr = expanded_ptr;
}
}
......
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