[WINESYNC]d3dx9_36: Support NULL terminated strings in ID3DXFont_DrawText

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>

wine-staging patch by Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
This commit is contained in:
winesync 2020-01-04 02:11:30 +01:00 committed by Jérôme Gardou
parent 54240ccee0
commit 219ef2e81f
3 changed files with 146 additions and 2 deletions

View file

@ -213,9 +213,12 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n",
iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color);
if (!string || count <= 0)
if (!string || count == 0)
return 0;
if (count < 0)
count = -1;
countW = MultiByteToWideChar(CP_ACP, 0, string, count, NULL, 0);
stringW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR));
if (stringW)
@ -238,9 +241,12 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n",
iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color);
if (!string || count <= 0)
if (!string || count == 0)
return 0;
if (count < 0)
count = lstrlenW(string);
/* Strip terminating NULL characters */
while (count > 0 && !string[count-1])
count--;