@@ -491,7 +491,11 @@ const ControlInfoMap::mapped_type &ControlInfoMap::at(unsigned int id) const
*/
ControlInfoMap::size_type ControlInfoMap::count(unsigned int id) const
{
- return count(idmap_.at(id));
+ auto iter = idmap_.find(id);
+ if (iter == idmap_.end())
+ return 0;
+
+ return count(iter->second);
}
/**
@@ -502,7 +506,11 @@ ControlInfoMap::size_type ControlInfoMap::count(unsigned int id) const
*/
ControlInfoMap::iterator ControlInfoMap::find(unsigned int id)
{
- return find(idmap_.at(id));
+ auto iter = idmap_.find(id);
+ if (iter == idmap_.end())
+ return end();
+
+ return find(iter->second);
}
/**
@@ -513,7 +521,11 @@ ControlInfoMap::iterator ControlInfoMap::find(unsigned int id)
*/
ControlInfoMap::const_iterator ControlInfoMap::find(unsigned int id) const
{
- return find(idmap_.at(id));
+ auto iter = idmap_.find(id);
+ if (iter == idmap_.end())
+ return end();
+
+ return find(iter->second);
}
/**
The ControlList count() and find() methods use at() to lookup the control numerical ID in the idmap_. This causes an exception to be thrown if the ID doesn't exist in the map. Fix it by using the find() method instead. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/libcamera/controls.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)