Commit e9e19b5b authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Dave Airlie

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

Found thanks to amaerican fuzzy lop.
Signed-off-by: default avatarMarc-André Lureau <>
parent a342dc91
......@@ -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);
LIST_FOR_EACH_ENTRY_SAFE(sub, tmp, &ctx->sub_ctxs, head)
......@@ -3902,6 +3904,9 @@ bool vrend_destroy_context(struct vrend_context *ctx)
if (!switch_0 && cur)
vrend_hw_switch_context(cur, true);
return switch_0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment