summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Williams <taaparthur@disroot.org>2023-08-12 19:32:41 -0700
committersfan5 <sfan5@live.de>2023-08-20 00:29:57 +0200
commit19384e07e4a34a2f6eb54da8d683d5536d4b694b (patch)
tree99403a202a2aca501d3bea503d951a30e116cf70
parent2791eb64e8526b97cef4f7c9a907f665b55e199a (diff)
downloadmpv-19384e07e4a34a2f6eb54da8d683d5536d4b694b.tar.bz2
mpv-19384e07e4a34a2f6eb54da8d683d5536d4b694b.tar.xz
context_drm_egl: don't free egl properties if they are null
If we failed to create a gbm surface, we would call drm_egl_uninit to free up any state we had allocated. However, we would segfault if we tried to cleanup properties there were never initialized. Null checks have been added to guard against this.
-rw-r--r--video/out/opengl/context_drm_egl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c
index abd3e99c3b..b59e8dde81 100644
--- a/video/out/opengl/context_drm_egl.c
+++ b/video/out/opengl/context_drm_egl.c
@@ -497,9 +497,12 @@ static void drm_egl_uninit(struct ra_ctx *ctx)
eglMakeCurrent(p->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
- eglDestroyContext(p->egl.display, p->egl.context);
- eglDestroySurface(p->egl.display, p->egl.surface);
- gbm_surface_destroy(p->gbm.surface);
+ if (p->egl.display) {
+ eglDestroyContext(p->egl.display, p->egl.context);
+ eglDestroySurface(p->egl.display, p->egl.surface);
+ }
+ if (p->gbm.surface)
+ gbm_surface_destroy(p->gbm.surface);
eglTerminate(p->egl.display);
gbm_device_destroy(p->gbm.device);
p->egl.context = EGL_NO_CONTEXT;