From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/d3dcompiler_43/compiler.c | 2 ++ dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 8fb38cf592c..d3c7b81df12 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -462,6 +462,8 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen if (secondary_flags) FIXME("Ignoring secondary flags %#x.\n", secondary_flags);
+ if (shader_blob) + *shader_blob = NULL; if (messages_blob) *messages_blob = NULL;
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index a24cb9692e9..15af598c90d 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -1412,7 +1412,8 @@ static void test_fail(void) { for (i = 0; i < ARRAY_SIZE(tests); ++i) { - compiled = errors = NULL; + errors = NULL; + compiled = (void *)0xdeadbeef; hr = D3DCompile(tests[i], strlen(tests[i]), NULL, NULL, NULL, "test", targets[j], 0, 0, &compiled, &errors); ok(hr == E_FAIL, "Test %u, target %s: Got unexpected hr %#lx.\n", i, targets[j], hr); ok(!!errors, "Test %u, target %s, expected non-NULL error blob.\n", i, targets[j]);
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/d3dcompiler_43/compiler.c | 2 +- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index d3c7b81df12..a3c7b22581f 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -556,7 +556,7 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen vkd3d_shader_free_messages(messages); }
- if (!ret) + if (!ret && shader_blob) { if (FAILED(hr = D3DCreateBlob(byte_code.size, shader_blob))) { diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 15af598c90d..b52b840f3bf 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -1742,6 +1742,22 @@ static void test_include(void) delete_directory(L"include"); }
+static void test_no_output_blob(void) +{ + static const char vs_source[] = + "float4 main(float4 pos : POSITION, inout float2 texcoord : TEXCOORD0) : POSITION\n" + "{\n" + " return pos;\n" + "}"; + ID3D10Blob *errors; + HRESULT hr; + + errors = (void *)0xdeadbeef; + hr = D3DCompile(vs_source, strlen(vs_source), NULL, NULL, NULL, "main", "vs_2_0", 0, 0, NULL, &errors); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!errors, "Unexpected errors blob.\n"); +} + START_TEST(hlsl_d3d9) { HMODULE mod; @@ -1770,4 +1786,5 @@ START_TEST(hlsl_d3d9) test_constant_table(); test_fail(); test_include(); + test_no_output_blob(); }
Matteo Bruni (@Mystral) commented about dlls/d3dcompiler_43/compiler.c:
} return hresult_from_vkd3d_result(ret);
}
This can leak byte_code.