Hans-Kristian Arntzen : vkd3d: Deal with Map out parameter being NULL.

Alexandre Julliard julliard at winehq.org
Tue Oct 1 15:42:40 CDT 2019


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

Author: Hans-Kristian Arntzen <post at arntzen-software.no>
Date:   Tue Oct  1 15:53:35 2019 +0200

vkd3d: Deal with Map out parameter being NULL.

It is possible to map a resource, but not disclose the VA to caller.
This is used for WriteToSubresource.

Signed-off-by: Hans-Kristian Arntzen <post at arntzen-software.no>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d/resource.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 88f184d..f9738f3 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -423,7 +423,8 @@ static HRESULT d3d12_heap_map(struct d3d12_heap *heap, uint64_t offset,
     if ((rc = pthread_mutex_lock(&heap->mutex)))
     {
         ERR("Failed to lock mutex, error %d.\n", rc);
-        *data = NULL;
+        if (data)
+            *data = NULL;
         return hresult_from_errno(rc);
     }
 
@@ -456,13 +457,15 @@ static HRESULT d3d12_heap_map(struct d3d12_heap *heap, uint64_t offset,
     if (hr == S_OK)
     {
         assert(heap->map_ptr);
-        *data = (BYTE *)heap->map_ptr + offset;
+        if (data)
+            *data = (BYTE *)heap->map_ptr + offset;
         ++resource->map_count;
     }
     else
     {
         assert(!heap->map_ptr);
-        *data = NULL;
+        if (data)
+            *data = NULL;
     }
 
     pthread_mutex_unlock(&heap->mutex);
@@ -1235,7 +1238,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
     if (FAILED(hr = d3d12_heap_map(resource->heap, resource->heap_offset, resource, data)))
         WARN("Failed to map resource %p, hr %#x.\n", resource, hr);
 
-    TRACE("Returning pointer %p.\n", *data);
+    if (data)
+        TRACE("Returning pointer %p.\n", *data);
 
     return hr;
 }




More information about the wine-cvs mailing list