[PATCH] apps: cam: Fix colorSpace access crash in KMSSink::configure

Milan Zamazal mzamazal at redhat.com
Mon Mar 10 12:06:30 CET 2025


cfg.colorSpace may be unset in KMSSink::configure, resulting in a crash
when it is accessed.  If cfg.colorSpace is unset, simply return, the
same way as when YcbcrEncoding is set to None.

Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
---
 src/apps/cam/kms_sink.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/apps/cam/kms_sink.cpp b/src/apps/cam/kms_sink.cpp
index 672c985a..aa9459cf 100644
--- a/src/apps/cam/kms_sink.cpp
+++ b/src/apps/cam/kms_sink.cpp
@@ -153,7 +153,8 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config)
 	colorEncoding_ = std::nullopt;
 	colorRange_ = std::nullopt;
 
-	if (cfg.colorSpace->ycbcrEncoding == libcamera::ColorSpace::YcbcrEncoding::None)
+	if (!cfg.colorSpace ||
+	    cfg.colorSpace->ycbcrEncoding == libcamera::ColorSpace::YcbcrEncoding::None)
 		return 0;
 
 	/*
-- 
2.48.1



More information about the libcamera-devel mailing list