From 0f7bb922ba398dd75f58ec0ceeacb33ea4e8c9ce Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Wed, 29 Jan 2025 16:39:44 -0300 Subject: [PATCH] tests/shader_runner: Pass the correct buffer size to swprintf() in dxc_compiler_compile_shader(). swprintf() expects the length of the buffer in WCHARs instead of bytes, so ARRAY_SIZE() is used instead of sizeof(). This caused almost all tests to terminate abruptly with the following message, in my machine: *** buffer overflow detected ***: terminated --- tests/shader_runner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 0a0ec1c5..78d831e3 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1623,7 +1623,7 @@ static HRESULT dxc_compiler_compile_shader(void *dxc_compiler, const char *profi *blob_out = NULL; - swprintf(wprofile, sizeof(wprofile), L"%hs", profile); + swprintf(wprofile, ARRAY_SIZE(wprofile), L"%hs", profile); if (FAILED(hr = dxc_compile(dxc_compiler, wprofile, compile_options, enable_16bit_types, hlsl, &blob))) return hr;