diff --git a/AK/printf.cpp b/AK/printf.cpp index 4bdc241fdaa..73d13594d08 100644 --- a/AK/printf.cpp +++ b/AK/printf.cpp @@ -49,7 +49,7 @@ ALWAYS_INLINE int printNumber(PutChFunc putch, char*& bufptr, dword number, bool } size_t numlen = p - buf; - if (!fieldWidth) + if (!fieldWidth || fieldWidth < numlen) fieldWidth = numlen; if (!leftPad) { for (unsigned i = 0; i < fieldWidth - numlen; ++i) { @@ -72,7 +72,7 @@ template ALWAYS_INLINE int printString(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth) { size_t len = strlen(str); - if (!fieldWidth) + if (!fieldWidth || fieldWidth < len) fieldWidth = len; if (!leftPad) { for (unsigned i = 0; i < fieldWidth - len; ++i)