LibC: Automatically append null terminator in vswprintf

This commit is contained in:
safarp 2022-03-20 08:52:56 +01:00 committed by Tim Flynn
parent 96db8d64f6
commit b0b8d14a2c
Notes: sideshowbarker 2024-07-17 17:03:32 +09:00

View file

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