From patchwork Tue Nov 17 13:24:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 10444 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 37100BE082 for ; Tue, 17 Nov 2020 13:24:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C15463322; Tue, 17 Nov 2020 14:24:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MLx264wb"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CF93B6033B for ; Tue, 17 Nov 2020 14:24:35 +0100 (CET) Received: from localhost.localdomain (unknown [IPv6:2a01:e0a:169:7140:d5de:1f8c:872a:c380]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6935D2A3; Tue, 17 Nov 2020 14:24:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1605619475; bh=3fsMRR0qHd1viUL8kiMLJO11No0iH92uWuKCWAQUzNg=; h=From:To:Cc:Subject:Date:From; b=MLx264wbIPewPzj8L5MXfZ652uM8+Vi3i7eKbdcRLDPddfZ43an/heBz3E+sBTWPH CuwiuCIEEF+DNJZQv5D7JorsCo8c6gVHm90mUuSDI89GsBM9vad4Xoy3vFQSwvfUIZ rPibDEijbqnDuGRY3913IAIRaxafxODeTrNTlWNQ= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Nov 2020 14:24:32 +0100 Message-Id: <20201117132432.238405-1-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: Avoid accessing a non existent control X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When pushing a controlone should check if it exists before accessing it, in order to avoid raising abort and crash. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Kieran Bingham --- src/libcamera/delayed_controls.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index f1c5f890..422deee5 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -147,7 +147,11 @@ bool DelayedControls::queue(const ControlList &controls) /* Update with new controls. */ for (const auto &control : controls) { - const ControlId *id = device_->controls().idmap().at(control.first); + const ControlIdMap &idmap = device_->controls().idmap(); + if (idmap.find(control.first) == idmap.end()) + return false; + + const ControlId *id = idmap.at(control.first); if (delays_.find(id) == delays_.end()) return false;