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

Pavel Machek pavel at ucw.cz
Thu Dec 14 22:34:00 CET 2023


Without this patch, I get segfault instead of "Failed to get default
stream configuration" message.
    
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;
 		cfg.pixelFormat = formats.begin()->first;
 		cfg.size = formats.begin()->second[0].max;
 
-- 
People of Russia, stop Putin before his war on Ukraine escalates.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20231214/35e1008d/attachment.sig>


More information about the libcamera-devel mailing list