1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-18 13:55:36 -05:00

backend: egl: fix resource leak

Destroy context and surface as well in egl_deinit.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2022-09-29 19:09:59 +01:00
parent 0fe4e0a1d4
commit c1dc11f59c
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4

View file

@ -66,10 +66,20 @@ void egl_deinit(backend_t *base) {
gl_deinit(&gd->gl); gl_deinit(&gd->gl);
// Destroy GLX context // Destroy GLX context
if (gd->ctx) { if (gd->ctx != EGL_NO_CONTEXT) {
eglMakeCurrent(gd->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(gd->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(gd->display, gd->ctx); eglDestroyContext(gd->display, gd->ctx);
gd->ctx = 0; gd->ctx = EGL_NO_CONTEXT;
}
if (gd->target_win != EGL_NO_SURFACE) {
eglDestroySurface(gd->display, gd->target_win);
gd->target_win = EGL_NO_SURFACE;
}
if (gd->display != EGL_NO_DISPLAY) {
eglTerminate(gd->display);
gd->display = EGL_NO_DISPLAY;
} }
free(gd); free(gd);
@ -173,7 +183,7 @@ static backend_t *egl_init(session_t *ps) {
} }
gd->ctx = eglCreateContext(gd->display, target_cfg, NULL, NULL); gd->ctx = eglCreateContext(gd->display, target_cfg, NULL, NULL);
if (!gd->ctx) { if (gd->ctx == EGL_NO_CONTEXT) {
log_error("Failed to get GLX context."); log_error("Failed to get GLX context.");
goto end; goto end;
} }