{"id":9988,"url":"https://patchwork.libcamera.org/api/patches/9988/?format=json","web_url":"https://patchwork.libcamera.org/patch/9988/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20201007092239.41704-1-tomi.valkeinen@iki.fi>","date":"2020-10-07T09:22:36","name":"[libcamera-devel,1/4] cam: options: fix access to uninit variable","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a8c885cc0e0d27412bdbdfd35c9999c8c567dd20","submitter":{"id":70,"url":"https://patchwork.libcamera.org/api/people/70/?format=json","name":"Tomi Valkeinen","email":"tomi.valkeinen@iki.fi"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9988/mbox/","series":[{"id":1360,"url":"https://patchwork.libcamera.org/api/series/1360/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1360","date":"2020-10-07T09:22:36","name":"[libcamera-devel,1/4] cam: options: fix access to uninit variable","version":1,"mbox":"https://patchwork.libcamera.org/series/1360/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9988/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9988/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 354C3BEEDF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Oct 2020 09:23:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF52863C13;\n\tWed,  7 Oct 2020 11:23:24 +0200 (CEST)","from mail-lj1-x241.google.com (mail-lj1-x241.google.com\n\t[IPv6:2a00:1450:4864:20::241])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AAD0C6035F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Oct 2020 11:23:22 +0200 (CEST)","by mail-lj1-x241.google.com with SMTP id l13so1233729ljg.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 07 Oct 2020 02:23:22 -0700 (PDT)","from deskari.lan (91-152-83-50.elisa-laajakaista.fi.\n\t[91.152.83.50]) by smtp.gmail.com with ESMTPSA id\n\tn26sm258341ljg.133.2020.10.07.02.23.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 07 Oct 2020 02:23:21 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"nfnGlh6V\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=4V2i6L2nkUl5kfyEdjUktK9rgnrR+tdhx5llmPlWigg=;\n\tb=nfnGlh6VdXRXbU+Dir5r9ecfxYKjPl1D9wZRwggQPlsogxlF6lbQMDX8C28JWIEitn\n\tMX85XIUEC4GwBhgK2A4ax2xIVjR8F2MP9AO+CAp3FuArTi+jPVbQceGXY3Eg7HyeGhOV\n\toYtiP9LR+Qp2E3AkUYPV19tL+OYHcvB+IzcGPsrsg5S4H/qspaTOErYL1wyEtX2v67pE\n\tUDBPe6Dnrv6x9a7YGJLez7p8TZWeeH/TTU3P7bs9A2RIZm/piuOtqbOjXqUGB9Gobwc0\n\tYx5fK7tewCLXCJ5mOK1kHF+LVkllhDPKIO4qpt2vgTQtdHwwKmLcVbeUZVjnVpdbcEuy\n\tJvsw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:mime-version:content-transfer-encoding;\n\tbh=4V2i6L2nkUl5kfyEdjUktK9rgnrR+tdhx5llmPlWigg=;\n\tb=prqXwpzA3S+T9lUhOeo2aixatLMfzKZEhk6OLkCq791FULJwp6545nATNAE9LfsMq3\n\tbnj9zy9/XTLYyTYoh1yhqyZDctoU9SweOGV0rq8jkZEIqaZ8Fmp96npzcY0glLg6n4eQ\n\ti4FISmqZquah3yhJFtI7D9eM0nvioRGKNGE8cx59ehAMs7+n7YdqgzFkDezVKnAiiQTW\n\tcCj/EZNVACj2J1DRFIkxhzuhzBZxZq11CgsvmizcM64fmBa1d6rUpJ7Ca7K1Y/90Vj54\n\tSGLDibVS2BJNTIbaWy1WLtSKBh2VDPOs1VPTUn3uf0YTQhHPtPMjKKWtFjQRGWVzxOL5\n\tgOYQ==","X-Gm-Message-State":"AOAM530iSJNtlHkfJPwxfcW98lJwsonu/WCjUn9tlx9zDRVLJhiZgDtJ\n\t8THMxn57ny3Hf8MbR74DXoGtptCslxxK9A==","X-Google-Smtp-Source":"ABdhPJxjLQnY3ydXemTnMvkWPheeQHV2dKncyVIy+Y6A42r8mJNCho4NPICvdjDwTgahqjYCpx4c7Q==","X-Received":"by 2002:a2e:8942:: with SMTP id b2mr910368ljk.441.1602062601890; \n\tWed, 07 Oct 2020 02:23:21 -0700 (PDT)","From":"Tomi Valkeinen <tomi.valkeinen@iki.fi>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  7 Oct 2020 12:22:36 +0300","Message-Id":"<20201007092239.41704-1-tomi.valkeinen@iki.fi>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 1/4] cam: options: fix access to uninit\n\tvariable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"Tomi Valkeinen <tomi.valkeinen@iki.fi>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"operator[] doesn't check if the option exists in the values_ map, so it\ncan return a pointer to location outside the map.\n\nFix by returning an empty OptionValue if the option is not found.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>\n---\n src/cam/options.cpp | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)","diff":"diff --git a/src/cam/options.cpp b/src/cam/options.cpp\nindex 77b3cc1..8fc1c42 100644\n--- a/src/cam/options.cpp\n+++ b/src/cam/options.cpp\n@@ -61,7 +61,12 @@ bool OptionsBase<T>::isSet(const T &opt) const\n template<typename T>\n const OptionValue &OptionsBase<T>::operator[](const T &opt) const\n {\n-\treturn values_.find(opt)->second;\n+\tstatic const OptionValue s_empty;\n+\n+\tauto it = values_.find(opt);\n+\tif (it != values_.end())\n+\t\treturn it->second;\n+\treturn s_empty;\n }\n \n template<typename T>\n","prefixes":["libcamera-devel","1/4"]}