better integer size assertion suggested by usak

This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-04-25 04:33:08 +09:00
parent 83c1399af0
commit 48f36d3f0e
6 changed files with 27 additions and 27 deletions
+1 -1
View File
@@ -272,7 +272,7 @@ str_buf_cat(mrb_state *mrb, struct RString *s, const char *ptr, size_t len)
ptr = STR_PTR(s) + off;
}
memcpy(STR_PTR(s) + STR_LEN(s), ptr, len);
mrb_assert(total <= MRB_INT_MAX);
mrb_assert_int_fit(size_t, total, mrb_int, MRB_INT_MAX);
STR_SET_LEN(s, total);
STR_PTR(s)[total] = '\0'; /* sentinel */
}