[PATCH] wined3d: Check pointer before use

Józef Kucia joseph.kucia at gmail.com
Tue Apr 25 03:15:03 CDT 2017


On Tue, Apr 25, 2017 at 8:01 AM, Alistair Leslie-Hughes
<leslie_alistair at hotmail.com> wrote:
> Test was provided by Józef Kucia.
>
> Fixes https://bugs.winehq.org/show_bug.cgi?id=42873
>
> Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
> ---
>  dlls/d3d11/tests/d3d11.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
>  dlls/wined3d/context.c   |  2 +-
>  2 files changed, 59 insertions(+), 1 deletion(-)
>
> diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
> index dfe50c6287..2961cc06cb 100644
> --- a/dlls/d3d11/tests/d3d11.c
> +++ b/dlls/d3d11/tests/d3d11.c
> @@ -17567,6 +17567,63 @@ done:
>      release_test_context(&test_context);
>  }
>
> +static void test_destroyed_wined3d_context_query_poll(void)

FWIW, I'm not sure if we want to use this name for the test. I'm sorry
that I haven't mentioned this earlier in the bug report.

> --- a/dlls/wined3d/context.c
> +++ b/dlls/wined3d/context.c
> @@ -3968,7 +3968,7 @@ struct wined3d_context *context_reacquire(const struct wined3d_device *device,
>  {
>      struct wined3d_context *current_context;
>
> -    if (context->tid != GetCurrentThreadId())
> +    if (!context || context->tid != GetCurrentThreadId())
>          return NULL;
>
>      current_context = context_acquire(device, context->current_rt.texture,

I think it's fine to do a NULL check in context_reacquire(), and it
should be good enough in practice (i.e. this corner case shouldn't
matter much).
However we may want to handle this correctly in the future. I think it
may be good idea to add a similar test for D3D11_QUERY_OCCLUSION (or
replace this one). For the occlusion query we want to additionally
test the result of the query which is expected to be incorrect
(todo_wine).



More information about the wine-devel mailing list