Skip to content

Commit

Permalink
LibC: Automatically append null terminator in vswprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
safarp authored and trflynn89 committed Mar 20, 2022
1 parent 96db8d6 commit b0b8d14
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Userland/Libraries/LibC/wstdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit b0b8d14

Please sign in to comment.