[libcamera-devel] [PATCH v2 2/2] test: controls: control_info_map: Test default constructor
Jacopo Mondi
jacopo.mondi at ideasonboard.com
Wed Apr 5 10:21:18 CEST 2023
Hi Mattijs,
On Wed, Apr 05, 2023 at 10:14:31AM +0200, Mattijs Korpershoek wrote:
> ControlInfoMap can be default-constructed. In that case, some of its
> members (like idmap_) can be a nullptr, and ControlInfoMap.find() will segfault.
>
> Add a test with a default constructed ControlInfoMap to cover this.
>
> Signed-off-by: Mattijs Korpershoek <mkorpershoek at baylibre.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
Thanks
j
> ---
> test/controls/control_info_map.cpp | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/test/controls/control_info_map.cpp b/test/controls/control_info_map.cpp
> index db95945a1580..29b33515e48c 100644
> --- a/test/controls/control_info_map.cpp
> +++ b/test/controls/control_info_map.cpp
> @@ -75,6 +75,13 @@ protected:
> return TestFail;
> }
>
> + /* Test looking up a control on a default-constructed infoMap */
> + const ControlInfoMap emptyInfoMap;
> + if (emptyInfoMap.find(12345) != emptyInfoMap.end()) {
> + cerr << "find() on empty ControlInfoMap failed" << endl;
> + return TestFail;
> + }
> +
> return TestPass;
> }
> };
>
> --
> 2.39.2
>
More information about the libcamera-devel
mailing list