From b02d4f4d72c5e0f76f331ed07fdc8178842d9b1f Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Tue, 20 Aug 2024 21:10:13 +0200 Subject: [PATCH] output: avoid crashing on no crtc (#58) dual gpus can init with no crtc and later rescan for them, however getRenderFormats might be called before that happends and null ptr deref, guard against it. --- src/backend/drm/DRM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 66b7bb4..20e9165 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -1718,6 +1718,10 @@ size_t Aquamarine::CDRMOutput::getGammaSize() { } std::vector Aquamarine::CDRMOutput::getRenderFormats() { + if (!connector->crtc || !connector->crtc->primary || connector->crtc->primary->formats.empty()) { + backend->log(AQ_LOG_ERROR, "Can't get formats: no crtc"); + return {}; + } return connector->crtc->primary->formats; }