[PATCH v2 0/1] MR1370: d2d1: Silently ignore non-default state block implementations.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53915 Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> -- v2: d2d1: Silently ignore non-default state block implementations. https://gitlab.winehq.org/wine/wine/-/merge_requests/1370
From: Nikolay Sivov <nsivov(a)codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53915 Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/d2d1/device.c | 6 ++++-- dlls/d2d1/state_block.c | 6 +++++- dlls/d2d1/tests/d2d1.c | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 72781a48d10..89d17149ca4 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1735,11 +1735,12 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_Flush(ID2D1DeviceContext1 *i static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceContext1 *iface, ID2D1DrawingStateBlock *state_block) { - struct d2d_state_block *state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block); struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface); + struct d2d_state_block *state_block_impl; TRACE("iface %p, state_block %p.\n", iface, state_block); + if (!(state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block))) return; state_block_impl->drawing_state = render_target->drawing_state; if (render_target->text_rendering_params) IDWriteRenderingParams_AddRef(render_target->text_rendering_params); @@ -1751,11 +1752,12 @@ static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceCon static void STDMETHODCALLTYPE d2d_device_context_RestoreDrawingState(ID2D1DeviceContext1 *iface, ID2D1DrawingStateBlock *state_block) { - struct d2d_state_block *state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block); struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); + struct d2d_state_block *state_block_impl; TRACE("iface %p, state_block %p.\n", iface, state_block); + if (!(state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block))) return; if (context->target.type == D2D_TARGET_COMMAND_LIST) { struct d2d_command_list *command_list = context->target.command_list; diff --git a/dlls/d2d1/state_block.c b/dlls/d2d1/state_block.c index 7415471ce3a..770c165fd90 100644 --- a/dlls/d2d1/state_block.c +++ b/dlls/d2d1/state_block.c @@ -186,6 +186,10 @@ struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStat { if (!iface) return NULL; - assert(iface->lpVtbl == (ID2D1DrawingStateBlockVtbl *)&d2d_state_block_vtbl); + if (iface->lpVtbl != (ID2D1DrawingStateBlockVtbl *)&d2d_state_block_vtbl) + { + WARN("Unexpected state block vtbl %p.\n", iface->lpVtbl); + return NULL; + } return CONTAINING_RECORD(iface, struct d2d_state_block, ID2D1DrawingStateBlock1_iface); } diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 1dcce63381e..1935955ec84 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -1835,6 +1835,7 @@ static void test_state_block(BOOL d3d11) ID2D1Factory *factory; ULONG refcount; HRESULT hr; + void *ptr; static const D2D1_MATRIX_3X2_F identity = {{{ 1.0f, 0.0f, @@ -2078,6 +2079,15 @@ static void test_state_block(BOOL d3d11) refcount = IDWriteRenderingParams_Release(text_rendering_params1); ok(!refcount, "Rendering params %lu references left.\n", refcount); + + /* State block object pointer is validated, but does not result in an error state. */ + ptr = (void *)0xdeadbeef; + ID2D1RenderTarget_BeginDraw(rt); + ID2D1RenderTarget_SaveDrawingState(rt, (ID2D1DrawingStateBlock *)&ptr); + ID2D1RenderTarget_RestoreDrawingState(rt, (ID2D1DrawingStateBlock *)&ptr); + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + release_test_context(&ctx); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1370
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126192 Your paranoid android. === w10pro64_ar (testbot log) === WineRunTask.pl:error: The previous 1 run(s) terminated abnormally
On Tue Nov 15 15:42:20 2022 +0000, Nikolay Sivov wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/1370/diffs?diff_id=18721&start_sha=5c6bf19e7ee89bc0ec38838d0293f64afd594afd#0a5641ba01f61e9eda969890860e19c2269a989a_2083_2083) Thanks.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/1370#note_15854
participants (3)
-
Marvin -
Nikolay Sivov -
Nikolay Sivov (@nsivov)