vkd3d-utils: Null-terminate the output of D3DPreprocess().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58596
This commit is contained in:
Elizabeth Figura
2025-08-15 18:50:17 -05:00
committed by Henri Verbeet
parent f52dc8a89a
commit 446b59319b
Notes: Henri Verbeet 2025-09-10 12:03:47 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1697
2 changed files with 8 additions and 5 deletions

View File

@@ -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;

View File

@@ -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");
}