From 636b411b313092ef3198a91656a8184e58703607 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 13 Jul 2022 21:51:22 +0200 Subject: [PATCH] backends/drm: don't crash if importing a texture fails CCBUG: 456500 --- src/backends/drm/drm_backend.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index 03744241a7..4abf968154 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -647,7 +647,14 @@ std::shared_ptr DrmBackend::createDmaBufTexture(const QSize &size gbm_bo_destroy(bo); const auto eglBackend = static_cast(m_renderBackend); eglBackend->makeCurrent(); - return std::make_shared(eglBackend->importDmaBufAsTexture(attributes), attributes); + if (auto texture = eglBackend->importDmaBufAsTexture(attributes)) { + return std::make_shared(texture, attributes); + } else { + for (int i = 0; i < attributes.planeCount; ++i) { + ::close(attributes.fd[i]); + } + return nullptr; + } } DrmGpu *DrmBackend::primaryGpu() const