From 6abf8958612f1433629ec64e0406ab8294d231b0 Mon Sep 17 00:00:00 2001 From: scribam Date: Tue, 12 Dec 2023 22:43:18 +0100 Subject: [PATCH] egl: make sure display is valid before cleanup --- core/wsi/egl.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/wsi/egl.cpp b/core/wsi/egl.cpp index 1a73b1fa4..81a7042b9 100644 --- a/core/wsi/egl.cpp +++ b/core/wsi/egl.cpp @@ -164,13 +164,19 @@ bool EGLGraphicsContext::init() void EGLGraphicsContext::term() { preTerm(); - eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - if (context != EGL_NO_CONTEXT) - eglDestroyContext(display, context); - if (surface != EGL_NO_SURFACE) - eglDestroySurface(display, surface); + if (display != EGL_NO_DISPLAY) + { + eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (context != EGL_NO_CONTEXT) + eglDestroyContext(display, context); + + if (surface != EGL_NO_SURFACE) + eglDestroySurface(display, surface); + eglTerminate(display); + } context = EGL_NO_CONTEXT; surface = EGL_NO_SURFACE;