Skip to content

Commit

Permalink
TextOutU/GetTextExtentPoint32U: Clear out the wchar_t buffer before w…
Browse files Browse the repository at this point in the history
…riting.

This correctly terminates the resulting string in any case. :)
  • Loading branch information
nmlgc committed Aug 5, 2013
1 parent c230ad4 commit dd0712e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions win32_utf8/src/gdi32_dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ BOOL WINAPI TextOutU(
BOOL ret;
size_t lpString_len = c + 1;
VLA(wchar_t, lpString_w, lpString_len);
StringToUTF16(lpString_w, lpString, lpString_len);
ZeroMemory(lpString_w, lpString_len * sizeof(wchar_t));
StringToUTF16(lpString_w, lpString, c);
ret = TextOutW(hdc, x, y, lpString_w, wcslen(lpString_w));
VLA_FREE(lpString_w);
return ret;
Expand All @@ -64,7 +65,8 @@ BOOL APIENTRY GetTextExtentPoint32U(
BOOL ret;
size_t lpString_len = c + 1;
VLA(wchar_t, lpString_w, lpString_len);
StringToUTF16(lpString_w, lpString, lpString_len);
ZeroMemory(lpString_w, lpString_len * sizeof(wchar_t));
StringToUTF16(lpString_w, lpString, c);
ret = GetTextExtentPoint32W(hdc, lpString_w, wcslen(lpString_w), psizl);
VLA_FREE(lpString_w);
return ret;
Expand Down

0 comments on commit dd0712e

Please sign in to comment.