From adaa5e064a6149e1f8122cc55589f60b6f58f7ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Gu=C3=A9rin?= <libcg@protonmail.com>
Date: Tue, 19 Dec 2023 16:34:17 -0800
Subject: [PATCH 1/2] drm: fix NPE while in headless mode

caused by e810317
---
 src/drm.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/drm.cpp b/src/drm.cpp
index 59516c7..8759321 100644
--- a/src/drm.cpp
+++ b/src/drm.cpp
@@ -3337,6 +3337,7 @@ void drm_get_native_colorimetry( struct drm_t *drm,
 		*displayEOTF = EOTF_Gamma22;
 		*outputEncodingColorimetry = displaycolorimetry_709;
 		*outputEncodingEOTF = EOTF_Gamma22;
+		return;
 	}
 
 	*displayColorimetry = drm->connector->metadata.colorimetry;
-- 
2.42.0


From 08c56c656539c88b23d243869b00cf3dd33bcb1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Gu=C3=A9rin?= <libcg@protonmail.com>
Date: Wed, 20 Dec 2023 17:18:32 -0800
Subject: [PATCH 2/2] drm: fix other headless NPE

fixes a980d912
---
 src/drm.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/drm.cpp b/src/drm.cpp
index 8759321..d632128 100644
--- a/src/drm.cpp
+++ b/src/drm.cpp
@@ -2584,10 +2584,10 @@ int drm_prepare( struct drm_t *drm, bool async, const struct FrameInfo_t *frameI
 	assert( drm->req == nullptr );
 	drm->req = drmModeAtomicAlloc();
 
-	bool bConnectorSupportsHDR = drm->connector->metadata.supportsST2084;
-	bool bConnectorHDR = g_bOutputHDREnabled && bConnectorSupportsHDR;
-
 	if (drm->connector != nullptr) {
+		bool bConnectorSupportsHDR = drm->connector->metadata.supportsST2084;
+		bool bConnectorHDR = g_bOutputHDREnabled && bConnectorSupportsHDR;
+
 		if (drm->connector->has_colorspace) {
 			drm->connector->pending.colorspace = ( bConnectorHDR ) ? DRM_MODE_COLORIMETRY_BT2020_RGB : DRM_MODE_COLORIMETRY_DEFAULT;
 		}
-- 
2.42.0

