=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Set pointer to NULL if committed resource creation fails.

Alexandre Julliard julliard at winehq.org
Wed Sep 12 16:37:56 CDT 2018


Module: vkd3d
Branch: master
Commit: 150d1f0eb8c7b835d4c8f7c4a7e39579d73bc643
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=150d1f0eb8c7b835d4c8f7c4a7e39579d73bc643

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Wed Sep 12 15:19:57 2018 +0200

vkd3d: Set pointer to NULL if committed resource creation fails.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 c11f474..e8bf7c9 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 34b4fdf..5a39f0c 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;




More information about the wine-cvs mailing list