mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 20:05:06 +00:00
printfing a number or string bigger than the field width should not crash.
This commit is contained in:
parent
c7d5ce6b5a
commit
a8f36f72a8
1 changed files with 2 additions and 2 deletions
|
@ -49,7 +49,7 @@ ALWAYS_INLINE int printNumber(PutChFunc putch, char*& bufptr, dword number, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t numlen = p - buf;
|
size_t numlen = p - buf;
|
||||||
if (!fieldWidth)
|
if (!fieldWidth || fieldWidth < numlen)
|
||||||
fieldWidth = numlen;
|
fieldWidth = numlen;
|
||||||
if (!leftPad) {
|
if (!leftPad) {
|
||||||
for (unsigned i = 0; i < fieldWidth - numlen; ++i) {
|
for (unsigned i = 0; i < fieldWidth - numlen; ++i) {
|
||||||
|
@ -72,7 +72,7 @@ template<typename PutChFunc>
|
||||||
ALWAYS_INLINE int printString(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth)
|
ALWAYS_INLINE int printString(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth)
|
||||||
{
|
{
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
if (!fieldWidth)
|
if (!fieldWidth || fieldWidth < len)
|
||||||
fieldWidth = len;
|
fieldWidth = len;
|
||||||
if (!leftPad) {
|
if (!leftPad) {
|
||||||
for (unsigned i = 0; i < fieldWidth - len; ++i)
|
for (unsigned i = 0; i < fieldWidth - len; ++i)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue