LibC: Automatically append null terminator in vswprintf
This commit is contained in:
parent
96db8d64f6
commit
b0b8d14a2c
Notes:
sideshowbarker
2024-07-17 17:03:32 +09:00
Author: https://github.com/safarp Commit: https://github.com/SerenityOS/serenity/commit/b0b8d14a2c Pull-request: https://github.com/SerenityOS/serenity/pull/13147 Reviewed-by: https://github.com/trflynn89
1 changed files with 4 additions and 0 deletions
|
@ -207,6 +207,10 @@ int vswprintf(wchar_t* __restrict wcs, size_t max_length, wchar_t const* __restr
|
|||
++length_so_far;
|
||||
},
|
||||
wcs, fmt, args);
|
||||
if (length_so_far < max_length)
|
||||
wcs[length_so_far] = L'\0';
|
||||
else
|
||||
wcs[max_length - 1] = L'\0';
|
||||
return static_cast<int>(length_so_far);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue