Nikolay Sivov : d3d11: Always initialize out shader pointer in CreatePixelShader().

Alexandre Julliard julliard at winehq.org
Fri May 27 16:35:29 CDT 2022


Module: wine
Branch: master
Commit: 3dd9a78a1a3c7b69204969d26c44534bb19d0866
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3dd9a78a1a3c7b69204969d26c44534bb19d0866

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri May 27 14:54:20 2022 +0300

d3d11: Always initialize out shader pointer in CreatePixelShader().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>

---

 dlls/d3d10core/tests/d3d10core.c | 5 +++++
 dlls/d3d11/device.c              | 4 ++++
 dlls/d3d11/tests/d3d11.c         | 5 +++++
 3 files changed, 14 insertions(+)

diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c
index e292c27f7a1..d796087ef3f 100644
--- a/dlls/d3d10core/tests/d3d10core.c
+++ b/dlls/d3d10core/tests/d3d10core.c
@@ -3906,6 +3906,11 @@ void main(point float4 vin[1] : POSITION, inout TriangleStream<gs_out> vout)
     ok(!vs, "Unexpected pointer %p.\n", vs);
 
     /* pixel shader */
+    ps = (void *)0xdeadbeef;
+    hr = ID3D10Device_CreatePixelShader(device, vs_2_0, sizeof(vs_2_0), &ps);
+    ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+    ok(!ps, "Unexpected pointer %p.\n", ps);
+
     expected_refcount = get_refcount(device) + 1;
     hr = ID3D10Device_CreatePixelShader(device, ps_4_0, sizeof(ps_4_0), &ps);
     ok(SUCCEEDED(hr), "Failed to create SM4 pixel shader, hr %#x.\n", hr);
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index c2cb941ecb0..7b1c1b9bae0 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -3546,6 +3546,8 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device2 *i
     TRACE("iface %p, byte_code %p, byte_code_length %Iu, class_linkage %p, shader %p.\n",
             iface, byte_code, byte_code_length, class_linkage, shader);
 
+    *shader = NULL;
+
     if (class_linkage)
         FIXME("Class linkage is not implemented yet.\n");
 
@@ -6284,6 +6286,8 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device1 *i
     TRACE("iface %p, byte_code %p, byte_code_length %Iu, shader %p.\n",
             iface, byte_code, byte_code_length, shader);
 
+    *shader = NULL;
+
     if (FAILED(hr = d3d_pixel_shader_create(device, byte_code, byte_code_length, &object)))
         return hr;
 
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 2096e6d25c5..eb3ac35b824 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -4848,6 +4848,11 @@ static void test_create_shader(const D3D_FEATURE_LEVEL feature_level)
     ok(hr == S_OK, "Feature level %#x: Got unexpected hr %#lx.\n", feature_level, hr);
     ID3D11PixelShader_Release(ps);
 
+    ps = (void *)0xdeadbeef;
+    hr = ID3D11Device_CreatePixelShader(device, vs_2_0, sizeof(vs_2_0), NULL, &ps);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
+    ok(!ps, "Unexpected pointer %p.\n", ps);
+
     /* vertex shader */
     vs = (void *)0xdeadbeef;
     hr = ID3D11Device_CreateVertexShader(device, vs_2_0, sizeof(vs_2_0), NULL, &vs);




More information about the wine-cvs mailing list