Skip to content

Commit

Permalink
Check return value from snprintf(); ref #3498
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 11, 2017
1 parent f9ed15d commit e392231
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mrbgems/mruby-sprintf/src/sprintf.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1087,6 +1087,9 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)


CHECK(need); CHECK(need);
n = snprintf(&buf[blen], need, fbuf, fval); n = snprintf(&buf[blen], need, fbuf, fval);
if (n < 0) {
mrb_raise(mrb, E_RUNTIME_ERROR, "formatting error");
}
blen += n; blen += n;
} }
break; break;
Expand Down

0 comments on commit e392231

Please sign in to comment.