mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-utils: Null-terminate the output of D3DPreprocess().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58596
This commit is contained in:
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
@@ -484,7 +484,10 @@ HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename
|
|||||||
|
|
||||||
if (!ret)
|
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);
|
vkd3d_shader_free_shader_code(&preprocessed_code);
|
||||||
return hr;
|
return hr;
|
||||||
|
@@ -48,9 +48,9 @@ static void check_preprocess_(const char *file, int line, const char *source,
|
|||||||
}
|
}
|
||||||
code = ID3D10Blob_GetBufferPointer(blob);
|
code = ID3D10Blob_GetBufferPointer(blob);
|
||||||
size = ID3D10Blob_GetBufferSize(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);
|
(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)
|
if (present)
|
||||||
ok_(file, line)(vkd3d_memmem(code, size, present, strlen(present)),
|
ok_(file, line)(vkd3d_memmem(code, size, present, strlen(present)),
|
||||||
"\"%s\" not found in preprocessed shader.\n", 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",
|
todo ok(size == strlen(code) + 3, "Expected size %u, got %u.\n",
|
||||||
(unsigned int)strlen(code) + 3, (unsigned int)size);
|
(unsigned int)strlen(code) + 3, (unsigned int)size);
|
||||||
todo ok(code[size - 3] == 0, "Expected null termination, got %#x.\n", code[size - 3]);
|
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 - 2] == ' ', "Expected space, got %#x.\n", code[size - 2]);
|
||||||
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]);
|
||||||
ID3D10Blob_Release(blob);
|
ID3D10Blob_Release(blob);
|
||||||
ok(!errors, "Expected no errors.\n");
|
ok(!errors, "Expected no errors.\n");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user