mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 23:09:45 +03:00
libcamera: controls: Fix ControlInfoMap::count(unsigned int)
The two overloads of `find()` and `at()` have the same behaviour
regardless of the argument type: `unsigned int` or `const ControlId *`.
However, `count()` is not so because `count(unsigned int)` only checks
the `ControlIdMap`, and it does not check if the given id is actually
present in the map storing the `ControlInfo` objects.
So `count()` returns 1 for every control id that is present in the
associated `ControlIdMap` regardless of whether there is an actual
entry for the `ControlId` associated with the given numeric id.
Fix that by simply using `find()` to determine the return value.
Fixes: 76b9923e55
("libcamera: controls: Avoid exception in ControlInfoMap count() and find()")
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
969df3db31
commit
efdbe39698
1 changed files with 1 additions and 9 deletions
|
@ -857,15 +857,7 @@ const ControlInfoMap::mapped_type &ControlInfoMap::at(unsigned int id) const
|
|||
*/
|
||||
ControlInfoMap::size_type ControlInfoMap::count(unsigned int id) const
|
||||
{
|
||||
if (!idmap_)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* The ControlInfoMap and its idmap have a 1:1 mapping between their
|
||||
* entries, we can thus just count the matching entries in idmap to
|
||||
* avoid an additional lookup.
|
||||
*/
|
||||
return idmap_->count(id);
|
||||
return find(id) != end();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue