-- v2: d3d10: Handle invalid arguments for effect creation. d3d10/tests: Test NULL device for D3D10CreateEffectFromMemory and D3D10CreateEffectPoolFromMemory.
From: Ziqing Hui zhui@codeweavers.com
--- dlls/d3d10/tests/effect.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 3bd6d6d0ecc..bd856bb91d8 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -118,6 +118,12 @@ static void test_effect_constant_buffer_type(void) return; }
+ if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ + { + hr = create_effect(fx_test_ecbt, 0, NULL, NULL, &effect); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr); + } + hr = create_effect(fx_test_ecbt, 0, device, NULL, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
@@ -7117,6 +7123,12 @@ static void test_effect_pool(void) todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+ if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ + { + hr = create_effect_pool(fx_test_pool, NULL, &pool); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr); + } + hr = create_effect_pool(fx_test_pool, device, &pool); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
From: Ziqing Hui zhui@codeweavers.com
Passing NULL data to D3D10CreateEffectFromMemory crashes. Passing NULL data to D3D10CreateEffectPoolFromMemory returns E_INVALIDARG. --- dlls/d3d10/effect.c | 6 ++++++ dlls/d3d10/tests/effect.c | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 84ecfdcbbab..a9c8eaed5e8 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -9537,6 +9537,9 @@ static HRESULT d3d10_create_effect(void *data, SIZE_T data_size, ID3D10Device *d struct d3d10_effect *object; HRESULT hr;
+ if (!device) + return D3DERR_INVALIDCALL; + if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
@@ -9636,6 +9639,9 @@ HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UIN TRACE("data %p, data_size %Iu, fx_flags %#x, device %p, effect_pool %p.\n", data, data_size, fx_flags, device, effect_pool);
+ if (!data) + return E_INVALIDARG; + if (FAILED(hr = d3d10_create_effect(data, data_size, device, NULL, D3D10_EFFECT_IS_POOL, &object))) { diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index bd856bb91d8..25ac2d673ce 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -118,11 +118,8 @@ static void test_effect_constant_buffer_type(void) return; }
- if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ - { hr = create_effect(fx_test_ecbt, 0, NULL, NULL, &effect); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr); - }
hr = create_effect(fx_test_ecbt, 0, device, NULL, &effect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); @@ -7120,14 +7117,10 @@ static void test_effect_pool(void) ok(!!device2, "Failed to create d3d device.\n");
hr = D3D10CreateEffectPoolFromMemory(NULL, 0, 0, device, &pool); - todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
- if (strcmp(winetest_platform, "wine")) /* Crash on wine. */ - { hr = create_effect_pool(fx_test_pool, NULL, &pool); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr); - }
hr = create_effect_pool(fx_test_pool, device, &pool); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
This merge request was approved by Matteo Bruni.
Just for the records, it's fine if you combine the patches into one in this kind of situations where it's trivial to run the new test with the old implementation and thus verify the fix.
Leaving the patches separate is also fine of course.