From patchwork Mon Mar 8 17:10:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11520 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se 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 A16DABD80C for ; Mon, 8 Mar 2021 17:10:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5FD0A68AAC; Mon, 8 Mar 2021 18:10:07 +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="athxsjvF"; 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 4CE7268A9F for ; Mon, 8 Mar 2021 18:10:06 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 716CAE7B; Mon, 8 Mar 2021 18:10:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615223404; bh=YaCb/UKIQS35+wQKpQwuYz0ZboamERxCk/J/mLoe9cE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=athxsjvFlIS4aTgjwura4mG6Nfo4+nlEj6POlpqDBdHTJJQUBQS/Wm1dl2phbRwVU tus3s7q+jFItYjiVQ7x8mjL69vfw2PIbOWYqHYZGaDqUxR3h7RnskNhg/F97UUdsjW 6G8JLkpaIhNqtfBhQ4xMMdVNemhBtkngUv9cTiAA= From: Kieran Bingham To: libcamera devel Date: Mon, 8 Mar 2021 17:10:01 +0000 Message-Id: <20210308171001.529723-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210208102137.2164282-2-niklas.soderlund@ragnatech.se> References: <20210208102137.2164282-2-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] lc-compliance: Cache buffers size before destroy 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" The buffers.size is referenced after calling stop which destroys buffers. This causes a use-after-free. Cache the size so we can return the value appropriately in the test results. Signed-off-by: Kieran Bingham --- src/lc-compliance/simple_capture.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp index cfcad79ad655..88fb6a8187cc 100644 --- a/src/lc-compliance/simple_capture.cpp +++ b/src/lc-compliance/simple_capture.cpp @@ -80,8 +80,12 @@ Results::Result SimpleCaptureBalanced::capture(unsigned int numRequests) /* No point in testing less requests then the camera depth. */ if (buffers.size() > numRequests) { + /* Cache buffers.size() before we destroy it in stop() */ + int buffers_size = buffers.size(); stop(); - return { Results::Skip, "Camera needs " + std::to_string(buffers.size()) + " requests, can't test only " + std::to_string(numRequests) }; + + return { Results::Skip, "Camera needs " + std::to_string(buffers_size) + + " requests, can't test only " + std::to_string(numRequests) }; } queueCount_ = 0;