diff options
author | Bartosz Tomczyk <[email protected]> | 2017-04-29 16:37:45 +0200 |
---|---|---|
committer | Juan A. Suarez Romero <[email protected]> | 2017-06-01 04:25:10 +0200 |
commit | 580a2e6c15ca7f6e89d262224eb518100a2b4f8f (patch) | |
tree | f369669f87d2d342fc49cfeedfe908f047b94399 /src/mesa/main | |
parent | ce2b96dd8b5a6c4ea0c80c6c0f46652a0b591515 (diff) |
mesa: Avoid leaking surface in st_renderbuffer_delete
v2: add comment in code
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100741
Fixes: a5e733c6b52 mesa: drop current draw/read buffer when ctx is released
Reviewed-by: Rob Clark <[email protected]> (v1)
Reviewed-by: Emil Velikov <[email protected]>
(cherry picked from commit fd6c2a3f3eb7f5f3077fb95b1441ddaa43b806fe)
Signed-off-by: Juan A. Suarez Romero <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/context.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 8876ca2e246..77e11d2091e 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1654,17 +1654,23 @@ _mesa_make_current( struct gl_context *newCtx, _mesa_flush(curCtx); /* We used to call _glapi_check_multithread() here. Now do it in drivers */ - _glapi_set_context((void *) newCtx); - assert(_mesa_get_current_context() == newCtx); if (!newCtx) { _glapi_set_dispatch(NULL); /* none current */ + /* We need old ctx to correctly release Draw/ReadBuffer + * and avoid a surface leak in st_renderbuffer_delete. + * Therefore, first drop buffers then set new ctx to NULL. + */ if (curCtx) { _mesa_reference_framebuffer(&curCtx->WinSysDrawBuffer, NULL); _mesa_reference_framebuffer(&curCtx->WinSysReadBuffer, NULL); } + _glapi_set_context(NULL); + assert(_mesa_get_current_context() == NULL); } else { + _glapi_set_context((void *) newCtx); + assert(_mesa_get_current_context() == newCtx); _glapi_set_dispatch(newCtx->CurrentClientDispatch); if (drawBuffer && readBuffer) { |