From 19384e07e4a34a2f6eb54da8d683d5536d4b694b Mon Sep 17 00:00:00 2001 From: Arthur Williams Date: Sat, 12 Aug 2023 19:32:41 -0700 Subject: [PATCH] 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. --- video/out/opengl/context_drm_egl.c | 9 ++++++--- 1 file 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;