nv50: fix crash in nv50_pre_pipebuffer_map (nv50_screen->cur_ctx)
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Wed, 20 Jan 2010 22:27:07 +0000 (23:27 +0100)
committerBen Skeggs <bskeggs@redhat.com>
Sun, 24 Jan 2010 23:44:34 +0000 (09:44 +1000)
nv50_pre_pipebuffer_map references screen->cur_ctx which points
to freed memory after the context is destroyed.
This crash is easily triggerable by progs/xdemos/glxcontexts.

src/gallium/drivers/nv50/nv50_context.c

index e2198b189dad34d575d48b02a0b9dc5c4df95688..5c705ccc8f180c09fbf8c703e05ed508fda16727 100644 (file)
@@ -86,6 +86,10 @@ nv50_destroy(struct pipe_context *pipe)
                so_ref(NULL, &nv50->state.vtxattr);
 
        draw_destroy(nv50->draw);
+
+       if (nv50->screen->cur_ctx == nv50)
+               nv50->screen->cur_ctx = NULL;
+
        FREE(nv50);
 }