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

Kieran Bingham kieran.bingham at ideasonboard.com
Fri Mar 14 10:03:14 CET 2025


Quoting Milan Zamazal (2025-03-10 11:06:30)
> 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.

I think this is something that we should ensure is trapped by
lc-compliance in fact.

I believe pipeline handlers /must/ always set the correct colorSpace
after validate - so it's incorrect for applications to ever hit an
undefined color space ...

Of course crashing isn't nice either ... but is this occuring in
SoftISP/simple pipeline handler ?



> 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