mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
render/egl: prevent use-after-free when destroying current surface
This commit is contained in:
parent
fd25e2ca11
commit
51416738ea
1 changed files with 7 additions and 0 deletions
|
|
@ -646,5 +646,12 @@ bool wlr_egl_destroy_surface(struct wlr_egl *egl, EGLSurface surface) {
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
return true;
|
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);
|
return eglDestroySurface(egl->display, surface);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue