summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorentin Noël <corentin.noel@collabora.com>2023-08-25 12:28:49 +0200
committerCorentin Noël <corentin.noel@collabora.com>2023-08-25 12:32:02 +0200
commit6a595b3cf8396dee040d5da8b2add61fcbf7d23d (patch)
treebc06272691c5d64d74d4c98cc20cee8e7cf18a5e
parent409bd2e8fd014d67f6935d259b07647008186ce1 (diff)
renderer: Change the current subcontext to the currently deleted one on context destruction
Make sure to never leave dangling pointers and free subcontexts from the last to the first to make sure that we are freeing the context 0 in last. Signed-off-by: Corentin Noël <corentin.noel@collabora.com> Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1196>
-rw-r--r--src/vrend_renderer.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 1acdc01..16b7f43 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -7671,8 +7671,13 @@ void 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)
+ LIST_FOR_EACH_ENTRY_SAFE_REV(sub, tmp, &ctx->sub_ctxs, head) {
+ ctx->sub = sub;
vrend_destroy_sub_context(sub);
+ }
+ ctx->sub = NULL;
+ ctx->sub0 = NULL;
+
if(ctx->ctx_id)
vrend_renderer_force_ctx_0();