Console: don't use buf for '-' and '0' padding

As buf is not sized depending on the padding, if a huge padding is put
in buf then we could see an overflow.
This commit is contained in:
Alexandre Bique 2012-02-15 06:27:36 +01:00 committed by Norman Feske
parent a3266f8ec7
commit 42c21e4582
1 changed files with 2 additions and 2 deletions

View File

@ -188,7 +188,7 @@ void Console::_out_signed(T value, unsigned base)
/* add sign to buffer for negative values */
if (neg)
buf[i++] = '-';
_out_char('-');
/* output buffer in reverse order */
for (; i--; )
@ -223,7 +223,7 @@ void Console::_out_unsigned(T value, unsigned base, int pad)
/* add padding zeros */
for (; pad-- > 0; )
buf[i++] = ascii(0);
_out_char(ascii(0));
/* output buffer in reverse order */
for (; i--; )