diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index 7fed86f4f..b44f32509 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -484,7 +484,10 @@ HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename if (!ret) { - if (FAILED(hr = vkd3d_blob_create((void *)preprocessed_code.code, preprocessed_code.size, preprocessed_blob))) + /* vkd3d-shader output is null-terminated, but the null terminator isn't + * included in the size. Increase the size to account for that. */ + if (FAILED(hr = vkd3d_blob_create((void *)preprocessed_code.code, + preprocessed_code.size + 1, preprocessed_blob))) { vkd3d_shader_free_shader_code(&preprocessed_code); return hr; diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 95df3a5e4..d6ac9106e 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -48,9 +48,9 @@ static void check_preprocess_(const char *file, int line, const char *source, } code = ID3D10Blob_GetBufferPointer(blob); size = ID3D10Blob_GetBufferSize(blob); - todo ok(size == strlen(code) + 1, "Expected size %u, got %u.\n", + ok(size == strlen(code) + 1, "Expected size %u, got %u.\n", (unsigned int)strlen(code) + 1, (unsigned int)size); - todo ok(code[size - 1] == 0, "Expected null termination, got %#x.\n", code[size - 1]); + ok(code[size - 1] == 0, "Expected null termination, got %#x.\n", code[size - 1]); if (present) ok_(file, line)(vkd3d_memmem(code, size, present, strlen(present)), "\"%s\" not found in preprocessed shader.\n", present); @@ -506,8 +506,8 @@ static void test_preprocess(void) todo ok(size == strlen(code) + 3, "Expected size %u, got %u.\n", (unsigned int)strlen(code) + 3, (unsigned int)size); todo ok(code[size - 3] == 0, "Expected null termination, got %#x.\n", code[size - 3]); - ok(code[size - 2] == ' ', "Expected space, got %#x.\n", code[size - 2]); - todo ok(code[size - 1] == 0, "Expected null termination, got %#x.\n", code[size - 1]); + todo ok(code[size - 2] == ' ', "Expected space, got %#x.\n", code[size - 2]); + ok(code[size - 1] == 0, "Expected null termination, got %#x.\n", code[size - 1]); ID3D10Blob_Release(blob); ok(!errors, "Expected no errors.\n"); }