[PATCH vkd3d 06/11] vkd3d: Set pointer to NULL if committed resource creation fails.

Józef Kucia joseph.kucia at gmail.com
Wed Sep 12 08:19:57 CDT 2018


From: Józef Kucia <jkucia at codeweavers.com>

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 libs/vkd3d/device.c | 11 +++++++----
 tests/d3d12.c       |  9 +++++++++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index c11f474a28d2..e8bf7c957b58 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -1914,22 +1914,25 @@ static D3D12_HEAP_PROPERTIES * STDMETHODCALLTYPE d3d12_device_GetCustomHeapPrope
 static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource(ID3D12Device *iface,
         const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
         const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
-        const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID riid, void **resource)
+        const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource)
 {
     struct d3d12_device *device = impl_from_ID3D12Device(iface);
     struct d3d12_resource *object;
     HRESULT hr;
 
     TRACE("iface %p, heap_properties %p, heap_flags %#x,  desc %p, initial_state %#x, "
-            "optimized_clear_value %p, riid %s, resource %p.\n",
+            "optimized_clear_value %p, iid %s, resource %p.\n",
             iface, heap_properties, heap_flags, desc, initial_state,
-            optimized_clear_value, debugstr_guid(riid), resource);
+            optimized_clear_value, debugstr_guid(iid), resource);
 
     if (FAILED(hr = d3d12_committed_resource_create(device, heap_properties, heap_flags,
             desc, initial_state, optimized_clear_value, &object)))
+    {
+        *resource = NULL;
         return hr;
+    }
 
-    return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, riid, resource);
+    return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
 }
 
 static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap(ID3D12Device *iface,
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 34b4fdf101fb..5a39f0c1dfa1 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -1656,10 +1656,19 @@ static void test_create_committed_resource(void)
 
     /* A texture cannot be created on a UPLOAD heap. */
     heap_properties.Type = D3D12_HEAP_TYPE_UPLOAD;
+    resource = (void *)0xdeadbeef;
     hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
             &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL,
             &IID_ID3D12Resource, (void **)&resource);
     ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(!resource, "Got unexpected pointer %p.\n", resource);
+
+    resource = (void *)0xdeadbeef;
+    hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
+            &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL,
+            &IID_ID3D12Device, (void **)&resource);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(!resource, "Got unexpected pointer %p.\n", resource);
 
     /* A texture cannot be created on a READBACK heap. */
     heap_properties.Type = D3D12_HEAP_TYPE_READBACK;
-- 
2.16.4




More information about the wine-devel mailing list