mruby-sprintf/sprintf.c: check integer overflow before casting.
@@ -259,7 +259,7 @@ get_num(mrb_state *mrb, const char *p, const char *end, int *valp)
{
char *e;
mrb_int n;
- if (!mrb_read_int(p, end, &e, &n)) {
+ if (!mrb_read_int(p, end, &e, &n) || INT_MAX < n) {
return NULL;
}
*valp = (int)n;
