From patchwork Fri Mar 14 20:29:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22961 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 1CB97C32F7 for ; Fri, 14 Mar 2025 20:30:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4FB6468946; Fri, 14 Mar 2025 21:30:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="HMNFeEIH"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36DAA68777 for ; Fri, 14 Mar 2025 21:30:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741984203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/S2xWvVwFqyo0um4LJ5bkgVbFOmwXjqTH6RNtUr9J2s=; b=HMNFeEIHNowYMAMtvLc3kO7vQXhWggyA3+37PrxnguLTdYKvo6Mpm7SRMnW6LXXJyExB2e dsd5OglDG06OVm9t+srJuyehu2iq3rM4k7yvWkwekYko3m0fhBvorX2dJgwOGHs38nLc2p 1WSjPBU4yjN5iruJRs2EiOb/sk+5b88= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-281-MZsgWWWCPHSpzsJ45JvXeA-1; Fri, 14 Mar 2025 16:30:00 -0400 X-MC-Unique: MZsgWWWCPHSpzsJ45JvXeA-1 X-Mimecast-MFC-AGG-ID: MZsgWWWCPHSpzsJ45JvXeA_1741984199 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8A7F419560AB; Fri, 14 Mar 2025 20:29:59 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 07BD81954B3C; Fri, 14 Mar 2025 20:29:57 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Laurent Pinchart Subject: [RFC PATCH 1/7] apps: common: Fix flipped error condition Date: Fri, 14 Mar 2025 21:29:29 +0100 Message-ID: <20250314202943.112109-2-mzamazal@redhat.com> In-Reply-To: <20250314202943.112109-1-mzamazal@redhat.com> References: <20250314202943.112109-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2z77uOCstor1Gg0yEZOn6utYs-BVa_v4kefkIYV42_I_1741984199 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true 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 OptionsParser::childOption encounters an error, it returns nullptr and the corresponding option. The check for a nested parent checks for an error erroneously, leading not only to a wrong behaviour in case there's no error but also to a segmentation error in case of error due to `options' being set to nullptr and accessed later. Signed-off-by: Milan Zamazal --- src/apps/common/options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp index cae193cc..29a5d9c7 100644 --- a/src/apps/common/options.cpp +++ b/src/apps/common/options.cpp @@ -1095,7 +1095,7 @@ OptionsParser::childOption(const Option *parent, Options *options) std::tie(options, error) = childOption(parent->parent, options); /* Propagate the error all the way back up the call stack. */ - if (!error) + if (error) return { options, error }; }