From 00b21992c4e564e84f66545aef6d85e1aea4fd4c Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Thu, 1 Dec 2022 20:11:18 +0100 Subject: [PATCH] backends/drm: don't leak gbm surface if creating egl surface fails --- src/backends/drm/drm_gbm_surface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backends/drm/drm_gbm_surface.cpp b/src/backends/drm/drm_gbm_surface.cpp index d8840fa862..ee69afa89c 100644 --- a/src/backends/drm/drm_gbm_surface.cpp +++ b/src/backends/drm/drm_gbm_surface.cpp @@ -134,6 +134,7 @@ std::variant, GbmSurface::Error> GbmSurface::createS EGLSurface eglSurface = eglCreatePlatformWindowSurfaceEXT(backend->eglDisplay(), config, surface, nullptr); if (eglSurface == EGL_NO_SURFACE) { qCCritical(KWIN_DRM) << "Creating EGL surface failed!" << getEglErrorString(); + gbm_surface_destroy(surface); return Error::Unknown; } return std::make_shared(backend, size, format, QVector{}, flags, surface, eglSurface); @@ -153,6 +154,7 @@ std::variant, GbmSurface::Error> GbmSurface::createS EGLSurface eglSurface = eglCreatePlatformWindowSurfaceEXT(backend->eglDisplay(), config, surface, nullptr); if (eglSurface == EGL_NO_SURFACE) { qCCritical(KWIN_DRM) << "Creating EGL surface failed!" << getEglErrorString(); + gbm_surface_destroy(surface); return Error::Unknown; } return std::make_shared(backend, size, format, modifiers, 0, surface, eglSurface);