Permalink
Browse files

Use size_t to calculate bytes needed for array.

  • Loading branch information...
clayton-shopify committed Nov 29, 2016
1 parent 246a9a8 commit b633aa9ad466277cf583f60b8e424e516362f0bf
Showing with 1 addition and 4 deletions.
  1. +1 −4 src/array.c
View
@@ -20,15 +20,12 @@ static struct RArray*
ary_new_capa(mrb_state *mrb, mrb_int capa)
{
struct RArray *a;
mrb_int blen;
size_t blen;
if (capa > ARY_MAX_SIZE) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
blen = capa * sizeof(mrb_value);
if (blen < capa) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
a = (struct RArray*)mrb_obj_alloc(mrb, MRB_TT_ARRAY, mrb->array_class);
a->ptr = (mrb_value *)mrb_malloc(mrb, blen);

0 comments on commit b633aa9

Please sign in to comment.