From 2bfe84db19e59359205fa2d4aaf6c0d512f89004 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 11 Dec 2024 16:10:18 -0800 Subject: [PATCH] GPU: Fix D3D12_INTERNAL_StrToWStr returning the wrong length --- src/gpu/d3d12/SDL_gpu_d3d12.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c index f42c72bf80169a..480fc96452230e 100644 --- a/src/gpu/d3d12/SDL_gpu_d3d12.c +++ b/src/gpu/d3d12/SDL_gpu_d3d12.c @@ -3630,7 +3630,8 @@ static bool D3D12_INTERNAL_StrToWStr( Uint32 *outSize) { size_t inlen, result; - size_t outlen = wstrSize; + size_t outBytesLeft = wstrSize; + *outSize = 0; if (renderer->iconv == NULL) { renderer->iconv = SDL_iconv_open("WCHAR_T", "UTF-8"); @@ -3644,9 +3645,8 @@ static bool D3D12_INTERNAL_StrToWStr( &str, &inlen, (char **)&wstr, - &outlen); + &outBytesLeft); - *outSize = (Uint32)outlen; // Check... switch (result) { @@ -3660,6 +3660,7 @@ static bool D3D12_INTERNAL_StrToWStr( break; } + *outSize = (Uint32)wstrSize - outBytesLeft; return true; }