[libcamera-devel] [PATCH] Avoid segfault with bad configuration

Milan Zamazal mzamazal at redhat.com
Fri Dec 15 15:21:39 CET 2023


Pavel Machek via libcamera-devel <libcamera-devel at lists.libcamera.org> writes:

> Without this patch, I get segfault instead of "Failed to get default
> stream configuration" message.

It works for me, but ...

> Signed-off-by: Pavel Machek <pavel at ucw.cz>
>
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index bdc7bfe5..8a315bfd 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -1138,6 +1138,8 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Span<const StreamRo
>  	 */
>  	for ([[maybe_unused]] StreamRole role : roles) {
>  		StreamConfiguration cfg{ StreamFormats{ formats } };
> +		if (!formats.begin()->first)
> +			continue;

... shouldn't the condition be

  if (formats.empty())

?

And couldn't the check be applied on the whole loop (which looks weird to me
anyway and the preceding todo comment most likely applies)?

>  		cfg.pixelFormat = formats.begin()->first;
>  		cfg.size = formats.begin()->second[0].max;



More information about the libcamera-devel mailing list