Skip to content

Commit

Permalink
Under MRB_INT64, width may be bigger than INT_MAX; fix #3665
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed May 25, 2017
1 parent 9bca887 commit 3ef97e3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mrbgems/mruby-sprintf/src/sprintf.c
Expand Up @@ -1034,6 +1034,9 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
if ((flags & FWIDTH) && need < width)
need = width;

if (need < 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "width too big");
}
FILL(' ', need);
if (flags & FMINUS) {
if (sign)
Expand Down

0 comments on commit 3ef97e3

Please sign in to comment.