[PATCH v1] libcamera: camera: Fix clearing of stream associations before `validate()`
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Nov 25 13:17:05 CET 2024
Quoting Barnabás Pőcze (2024-11-25 00:08:37)
> 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()")
Ouch - I would not have spotted that!
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> 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