From patchwork Mon Jun 3 01:57:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Arias X-Patchwork-Id: 1336 Return-Path: Received: from dtc-mta-104-233.dattaweb.com (dtc-mta-104-233.dattaweb.com [200.58.104.233]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F30E660C2A for ; Mon, 3 Jun 2019 03:58:10 +0200 (CEST) Received: from c054-dr.dattaweb.com (c054.linux.backend [172.17.110.63]) by smarthost02.dattaweb.com (Postfix) with ESMTPS id 832324C1D0D for ; Sun, 2 Jun 2019 22:58:08 -0300 (-03) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=eamanu.com; s=mail; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version: Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pVFLB8sl3SVDcRKaAoTfwRVYZCqeRq0jbbjgOZD1QzI=; b=l+fEbb2Jo4HQOVAMpEKy7Yg4IU qrxbtwLcaGX3Uo3M4Vug6uea7x7NK7ZoiKQ/SyvLAh30I/WMw/9ISdMcHuLtXMRzfXULVct/cR+eC OCD2+MPvXWRS0Nw8CLwzDeMCbu6uXzIxoQBGXvlpACsf7gy6GEt1AEbT/8rKoQvbLueQ=; Received: from [181.92.78.23] (helo=localhost.localdomain) by c054-dr.dattaweb.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1hXcEg-0008By-W3; Sun, 02 Jun 2019 22:58:08 -0300 From: Emmanuel Arias To: libcamera-devel@lists.libcamera.org Date: Sun, 2 Jun 2019 22:57:49 -0300 Message-Id: <20190603015749.1311-1-eamanu@eamanu.com> X-Mailer: git-send-email 2.11.0 X-Spam-Score: 0.9 X-Spam-Score-Int: 9 X-Spam-Bar: / X-Spam-Report: Action: no action Symbol: ARC_NA(0.00) Symbol: RCVD_VIA_SMTP_AUTH(0.00) Symbol: FROM_HAS_DN(0.00) Symbol: TO_MATCH_ENVRCPT_ALL(0.00) Symbol: MIME_GOOD(-0.10) Symbol: TO_DN_NONE(0.00) Symbol: RCPT_COUNT_TWO(0.00) Symbol: MID_CONTAINS_FROM(1.00) Symbol: RCVD_COUNT_ONE(0.00) Symbol: FROM_EQ_ENVFROM(0.00) Symbol: MIME_TRACE(0.00) Symbol: ASN(0.00) Symbol: RCVD_TLS_ALL(0.00) Message-ID: 20190603015749.1311-1-eamanu@eamanu.com X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - c054-dr.dattaweb.com X-AntiAbuse: Original Domain - lists.libcamera.org X-AntiAbuse: Originator/Caller UID/GID - [502 502] / [502 502] X-AntiAbuse: Sender Address Domain - eamanu.com Subject: [libcamera-devel] [PATCH] Avoid Segmentation Fault when use --help parameter X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 01:58:11 -0000 When Cam::parseOptions receive help args return -EINTR and Cam::init return 0 to main. But the first if does not return EXIT_FAILURE and continue. That launch a SegFaults --- src/cam/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index dbf0491..d23390a 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -61,7 +61,7 @@ int CamApp::init(int argc, char **argv) ret = parseOptions(argc, argv); if (ret < 0) - return ret == -EINTR ? 0 : ret; + return ret == -EINTR ? -EINTR : ret; cm_ = CameraManager::instance(); @@ -196,7 +196,7 @@ int main(int argc, char **argv) if (app.init(argc, argv)) return EXIT_FAILURE; - + struct sigaction sa = {}; sa.sa_handler = &signalHandler; sigaction(SIGINT, &sa, nullptr);