From 684355dfcae0b1054b7cf62bb4146a88bb03b4b7 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 16 Jun 2019 19:24:44 +0200 Subject: [PATCH] [d3d11] Fix GetData parameter validation We're supposed to return an error if a null pointer is passed along with a non-zero DataSize. Fixes more wine test failures. --- src/d3d11/d3d11_context_imm.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 98549e537..b1200e684 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -60,22 +60,17 @@ namespace dxvk { void* pData, UINT DataSize, UINT GetDataFlags) { - if (!pAsync) + if (!pAsync || (DataSize && !pData)) return E_INVALIDARG; - // Make sure that we can safely write to the memory - // location pointed to by pData if it is specified. - if (DataSize == 0) - pData = nullptr; - - if (pData && pAsync->GetDataSize() != DataSize) { - Logger::err(str::format( - "D3D11: GetData: Data size mismatch", - "\n Expected: ", pAsync->GetDataSize(), - "\n Got: ", DataSize)); + // Check whether the data size is actually correct + if (DataSize && DataSize != pAsync->GetDataSize()) return E_INVALIDARG; - } + // Passing a non-null pData is actually allowed if + // DataSize is 0, but we should ignore that pointer + pData = DataSize ? pData : nullptr; + // Ensure that all query commands actually get // executed before trying to access the query SynchronizeCsThread();