diff options
author | Simon Ser <contact@emersion.fr> | 2019-10-22 23:43:15 +0200 |
---|---|---|
committer | Scott Anderson <ascent12@hotmail.com> | 2019-10-23 09:36:50 +0000 |
commit | 51416738eae1ab5c16cbaa97a4293dbc8c809b79 (patch) | |
tree | 134780d1029fce6e94e5ffe36f608a8b7a056e74 /render/egl.c | |
parent | fd25e2ca116f4c16f48aa62cabf46ce171f2bf41 (diff) |
render/egl: prevent use-after-free when destroying current surface
Diffstat (limited to 'render/egl.c')
-rw-r--r-- | render/egl.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/render/egl.c b/render/egl.c index 69fde225..cbd92cb9 100644 --- a/render/egl.c +++ b/render/egl.c @@ -646,5 +646,12 @@ bool wlr_egl_destroy_surface(struct wlr_egl *egl, EGLSurface surface) { if (!surface) { return true; } + if (eglGetCurrentContext() == egl->context && + eglGetCurrentSurface(EGL_DRAW) == surface) { + // Reset the current EGL surface in case it's the one we're destroying, + // otherwise the next wlr_egl_make_current call will result in a + // use-after-free. + wlr_egl_make_current(egl, NULL, NULL); + } return eglDestroySurface(egl->display, surface); } |