mesa: Fix use after free.

Reset the pointer to the earlier free st_context.
Check the st_context pointer before st_glFlush.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8195

Signed-off-by: Mykola Piatykop <mykola.piatykop@globallogic.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21656>
This commit is contained in:
Mykola Piatykop 2023-03-01 16:48:45 +02:00 committed by Marge Bot
parent cb588d5d6e
commit 25fcf0adc3
2 changed files with 4 additions and 1 deletions

View file

@ -1502,7 +1502,9 @@ _mesa_make_current( struct gl_context *newCtx,
curCtx->Const.ContextReleaseBehavior ==
GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH) {
FLUSH_VERTICES(curCtx, 0, 0);
st_glFlush(curCtx, 0);
if (curCtx->st){
st_glFlush(curCtx, 0);
}
}
if (!newCtx) {

View file

@ -371,6 +371,7 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
if (st->pipe && destroy_pipe)
st->pipe->destroy(st->pipe);
st->ctx->st = NULL;
FREE(st);
}