Skip to content
Permalink
Browse files
fixup! Check return value from snprintf(); ref #3498
  • Loading branch information
matz committed Mar 11, 2017
1 parent e392231 commit f30ec2dfb0217fd1426dbdfa1db22da51bbe73b5
Showing 1 changed file with 4 additions and 1 deletion.
@@ -1049,7 +1049,10 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
need = width;

CHECK(need + 1);
snprintf(&buf[blen], need + 1, "%*s", need, "");
n = snprintf(&buf[blen], need + 1, "%*s", need, "");
if (n < 0) {
mrb_raise(mrb, E_RUNTIME_ERROR, "formatting error");
}
if (flags & FMINUS) {
if (!isnan(fval) && fval < 0.0)
buf[blen++] = '-';

0 comments on commit f30ec2d

Please sign in to comment.