Skip to content

Commit

Permalink
Check if width is zero or negative before fill; fix #3347
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 17, 2016
1 parent 2edf15b commit 4325707
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mrbgems/mruby-sprintf/src/sprintf.c
Expand Up @@ -720,10 +720,10 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
CHECK(n); CHECK(n);
memcpy(buf+blen, c, n); memcpy(buf+blen, c, n);
blen += n; blen += n;
FILL(' ', width-1); if (width>0) FILL(' ', width-1);
} }
else { else {
FILL(' ', width-1); if (width>0) FILL(' ', width-1);
CHECK(n); CHECK(n);
memcpy(buf+blen, c, n); memcpy(buf+blen, c, n);
blen += n; blen += n;
Expand Down

0 comments on commit 4325707

Please sign in to comment.