mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
printfing a number or string bigger than the field width should not crash.
This commit is contained in:
parent
c7d5ce6b5a
commit
a8f36f72a8
Notes:
sideshowbarker
2024-07-19 18:35:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a8f36f72a89
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;
|
||||
if (!fieldWidth)
|
||||
if (!fieldWidth || fieldWidth < numlen)
|
||||
fieldWidth = numlen;
|
||||
if (!leftPad) {
|
||||
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)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
if (!fieldWidth)
|
||||
if (!fieldWidth || fieldWidth < len)
|
||||
fieldWidth = len;
|
||||
if (!leftPad) {
|
||||
for (unsigned i = 0; i < fieldWidth - len; ++i)
|
||||
|
|
Loading…
Add table
Reference in a new issue