From patchwork Wed Oct 28 08:57:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 10284 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 C536FC3B5C for ; Wed, 28 Oct 2020 08:57:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 46A08622F0; Wed, 28 Oct 2020 09:57:37 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BTbOIN7x"; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81A3962067 for ; Wed, 28 Oct 2020 09:57:35 +0100 (CET) Received: by mail-pl1-x643.google.com with SMTP id w11so2151475pll.8 for ; Wed, 28 Oct 2020 01:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WLBKaFc2xmK8hx09lZ7yw//Cc2rOlGDiuXjLjlSLM1U=; b=BTbOIN7xMH2wK3RSWLoHUvQjEDIyU75nMv3rGP92laeH26xAlMa9wnYIJ3TVp1w0jO f7rbqauR+wt2RKGYG/dGfkNfkCIuGfG4j71/u6jskfuwncIiPt8mvcufJf0o/6wz9aYp EjyAV/fftIfWbYpwJN9V8ys+v4baj4AbLoKdY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WLBKaFc2xmK8hx09lZ7yw//Cc2rOlGDiuXjLjlSLM1U=; b=KKRjr4b7rCQQdf8esAEMicqxq8+FHkrU3vx6SpN7rhXY+tdp2Kyks1zp1LjPbMSq7A hqzIa6fR+SORFWMoWzZfQwTs4kYdI1kHk4NiVZ38q2BtIYO6zvr8928f9RUw8bY+o5H8 bAAcecKzSNniyWjxqMaJ1TBV97OmVB9Sjfyl1xduLZSBftBURH8ibOUFbgsEXM6O+liL 1tkoWffQrnclilloA4anpA2Dx9w+V2GS1pyVBR2T2HBcNG78ObnqJUUpnXZJEHUvR/lb ndht0Mm92jKF+eSLSsYp3PMflM3QJ71Gw9ytyw+9qDsWhJhAdNuzpwf9GbaxEXpwzdK3 Qjiw== X-Gm-Message-State: AOAM533dStJtGVUqknifUSePLiN1L9EOsk1tWRaZv8tdKf5D6gx+bOrF gWZQN71y429DwzOvfuDIETjeAjWXNlM10Q== X-Google-Smtp-Source: ABdhPJw6PzEHGemfMTVJJMivbkX7CivKcAXwUXEpNrhUdmjikI9XDFq9R5ekfEuvrvMZ/rFAOgctww== X-Received: by 2002:a17:90b:3882:: with SMTP id mu2mr5810846pjb.112.1603875453288; Wed, 28 Oct 2020 01:57:33 -0700 (PDT) Received: from hiroh.tok.corp.google.com ([2401:fa00:8f:2:de4a:3eff:fe7d:f78f]) by smtp.gmail.com with ESMTPSA id i1sm5074667pfa.168.2020.10.28.01.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 01:57:32 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Oct 2020 17:57:26 +0900 Message-Id: <20201028085726.2983867-1-hiroh@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] android: camera_device: Fix crash of accessing a missing map element 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" std::map::at() searches std::map by the given key. The commit e1f9fdb8a5bd096faa34d54804afa48d46d59b28 uses it with 0 to intend to accessing the first element of the map, but actually access the element whose key is nullptr. This causes the crash because the map doesn't have the element with nullptr. This fixes the issue by replacing the std::map::at() operation by std::map::begin(). Signed-off-by: Hirokazu Honda Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.29.0.rc2.309.g374f81d7ae-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ca60f51..ead8a43 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1525,7 +1525,7 @@ void CameraDevice::requestComplete(Request *request) * It might be appropriate to return a 'correct' (as determined by * pipeline handlers) timestamp in the Request itself. */ - uint64_t timestamp = buffers.at(0)->metadata().timestamp; + uint64_t timestamp = buffers.begin()->second->metadata().timestamp; resultMetadata = getResultMetadata(descriptor->frameNumber_, timestamp); /* Handle any JPEG compression. */