diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-10-27 23:51:02 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-11-20 21:47:42 +0200 |
commit | 7cbd88fec72643ff2bbe8c2ea43b25ad7bd31ca9 (patch) | |
tree | 085d03f819289492385fbb1a571a8e33dbdc7432 | |
parent | cdc68bf7f775538bcc58ff85a14cf89fc6c8668e (diff) |
libcamera: controls: Catch type mismatch in ControlInfoMap
ControlInfoMap requires the ControlId and ControlRange of each entry to
have identical types. Check for this and log an error if a mismatch is
detected.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r-- | src/libcamera/controls.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 594fed84..7d8a0e97 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -573,8 +573,19 @@ ControlInfoMap::const_iterator ControlInfoMap::find(unsigned int id) const void ControlInfoMap::generateIdmap() { idmap_.clear(); - for (const auto &ctrl : *this) + + for (const auto &ctrl : *this) { + if (ctrl.first->type() != ctrl.second.min().type()) { + LOG(Controls, Error) + << "Control " << utils::hex(ctrl.first->id()) + << " type and range type mismatch"; + idmap_.clear(); + clear(); + return; + } + idmap_[ctrl.first->id()] = ctrl.first; + } } /** |