Console: avoid to use buf for '-' and '0' padding chars

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
parent c41a2a8279
commit 9593d59b3a

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--; )