diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-02-03 18:14:23 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-02-10 12:39:48 +1000 |
commit | e9e19b5b479e3f045fc36bec8dfeb4717056d18b (patch) | |
tree | 7a0abd4bea33ed35af695e7feb352cd8d48c329a | |
parent | a342dc9149b435012a70d51bbeee21fa6e1b158b (diff) |
renderer: switch to context 0 before destroy sub
If the current context is one of the subcontext to be destroyed,
vrend_destroy_sub_context() will fail after the last context is
destroyed.
Found thanks to amaerican fuzzy lop.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r-- | src/vrend_renderer.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index d0ca2e0..8936720 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -3870,6 +3870,7 @@ static void vrend_destroy_sub_context(struct vrend_sub_context *sub) bool vrend_destroy_context(struct vrend_context *ctx) { bool switch_0 = (ctx == vrend_state.current_ctx); + struct vrend_context *cur = vrend_state.current_ctx; struct vrend_sub_context *sub, *tmp; if (switch_0) { vrend_state.current_ctx = NULL; @@ -3893,6 +3894,7 @@ bool vrend_destroy_context(struct vrend_context *ctx) vrend_set_index_buffer(ctx, 0, 0, 0); + vrend_renderer_force_ctx_0(); LIST_FOR_EACH_ENTRY_SAFE(sub, tmp, &ctx->sub_ctxs, head) vrend_destroy_sub_context(sub); @@ -3902,6 +3904,9 @@ bool vrend_destroy_context(struct vrend_context *ctx) FREE(ctx); + if (!switch_0 && cur) + vrend_hw_switch_context(cur, true); + return switch_0; } |