From 7cbd88fec72643ff2bbe8c2ea43b25ad7bd31ca9 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 27 Oct 2019 23:51:02 +0200 Subject: libcamera: controls: Catch type mismatch in ControlInfoMap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/controls.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/libcamera/controls.cpp') 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; + } } /** -- cgit v1.2.1