[libcamera-devel] [PATCH v2] libcamera: pipeline: simple: Only connect created converters

Kieran Bingham kieran.bingham at ideasonboard.com
Fri Oct 23 12:11:54 CEST 2020


If converter_->open() fails, the code deletes the converter_ but then
happily goes on, and at the very next lines will use converter_ to
connect the bufferReady signal.

Ensure the converter is only connected when successfully opened by
extending the conditional and connecting in an else scope instead.

Reported-by: Tomi Valkeinen <tomi.valkeinen at iki.fi>
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 src/libcamera/pipeline/simple/simple.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 0d48e1b6acca..3d2039f3f269 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -774,9 +774,9 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)
 				<< "Failed to open converter, disabling format conversion";
 			delete converter_;
 			converter_ = nullptr;
+		} else {
+			converter_->bufferReady.connect(this, &SimplePipelineHandler::converterDone);
 		}
-
-		converter_->bufferReady.connect(this, &SimplePipelineHandler::converterDone);
 	}
 
 	/*
-- 
2.25.1



More information about the libcamera-devel mailing list