[libcamera-devel] [PATCH v2 2/2] test: controls: control_info_map: Test default constructor
Umang Jain
umang.jain at ideasonboard.com
Mon Apr 17 08:22:47 CEST 2023
Hi Mattijs
On 4/5/23 1:44 PM, Mattijs Korpershoek via libcamera-devel 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: Umang Jain <umang.jain at ideasonboard.com>
> ---
> 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;
> }
> };
>
More information about the libcamera-devel
mailing list