[PATCH v1] libcamera: camera: Fix clearing of stream associations before `validate()`

Barnabás Pőcze pobrn at protonmail.com
Mon Nov 25 01:08:37 CET 2024


A copy is made in the range-based for loop, and thus `setStream()`
operates on this copy, leading to the `stream_` member of the given
`StreamConfiguration` object in `*config` never being set to `nullptr`.

Fix that by taking a reference in the range-based for loop.

Also rename the variable from `it` since it is not an iterator.

Fixes: 4217c9f1aa863c ("libcamera: camera: Zero streams before validate()")
---
 src/libcamera/camera.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 25135d46..82a5186a 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -1178,8 +1178,8 @@ int Camera::configure(CameraConfiguration *config)
 	if (ret < 0)
 		return ret;
 
-	for (auto it : *config)
-		it.setStream(nullptr);
+	for (auto &cfg : *config)
+		cfg.setStream(nullptr);
 
 	if (config->validate() != CameraConfiguration::Valid) {
 		LOG(Camera, Error)
-- 
2.47.0




More information about the libcamera-devel mailing list