From patchwork Wed Sep 7 16:35:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Utkarsh Tiwari X-Patchwork-Id: 17308 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 59A67C0DA4 for ; Wed, 7 Sep 2022 16:35:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6E31462089; Wed, 7 Sep 2022 18:35:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1662568528; bh=hQrDcAxVTMqYFLp45Cb5sEcs2HEEP3e3ICX+tlOulaM=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VaQaPSih6fZ9kgK4QswRpL/0e4SINBLNRNtn013xQLchOKfenfyE8HV9UmJwzPL+o MZ58Vm4bQoSi0ArzhLsM5eLkZKsktDCPocWHKkOhsdsAi4IVHqhHcNaBehBNY4vmvo rHAfrPx25EOrbmWEedpIlCR6a+m5P6tmoQaisfQ6pRy0lL7v9CPtbOkURZT1htBFBx g66wsXMvUqykE6dNIQo8FzrBN8Fr1EW0pQCDApJvLdV7UCteLekF3MIQNfhuxhuTq9 KJ1RLaVS+bkogIpbKJpxu6kYYZ/w3ixIT6yAJFp5Fj6TCrgWmEr5jJI0ICIY+wYG0K DJ3Qp/vKK6SwA== Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B9BA62054 for ; Wed, 7 Sep 2022 18:35:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jgVRTCe3"; dkim-atps=neutral Received: by mail-pf1-x431.google.com with SMTP id z187so15160209pfb.12 for ; Wed, 07 Sep 2022 09:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=AUJI/ZIj2Br9El6CjsxhM5HOq3u4Ihq6IzC7/A/abpg=; b=jgVRTCe3IHQzQOVYqq+XQOszGTxmGaGgO6uctiWkseKeOLbAYK5oMQCBpnrWh6O0rN YcDbWRG1EEx7a8NhVvpecdJBIMIc/WghwRyG8fkSIwIQxvpj5QVNBlx9IL4jRjxncZ30 e3AYojkqdA5PwWmvSkBrIPNGc/DfBq3YO3mPJHZV5KNtlN4hUeK7lV4p3VuMOjd+9+eY jKYR5N2uTOUpp8/LNuI7SM5Lv5Xndvv23iHfpXbtYrneIQPvbWxmcO3kLpe3i/PBD8s2 ndYI67e3sfTEKSYV0RcGoQ4ZxrkwN52AskpZgrhFz6uTx6SZcsoS6ygYdBx5ZZg7PU1L xOkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=AUJI/ZIj2Br9El6CjsxhM5HOq3u4Ihq6IzC7/A/abpg=; b=XYWK6qvuchEwmPMCfUBjAMi4aqHKefGMelMzyMNyDQuAqE1Jzgww+Q71WCfi18Ysr+ zgWNe5CPWtYOVuDtZmQGiIxNxhD3R8vlyQCjYZMzE8/scYst6DMvTwvqZKR5sik5pZzy mIUsRl+su2PbV1HiAkN6reVjWc9u8/+A97USMoTD2Yt5MytvqLWp1cDlppsyzHAcIbGH zUAddBO2DmEkMC2fNL8hyMxOzLWYIR1wcuLWymhkNwfm1QyZgMtS3615rG2pAJraN+Be HULifkCpD8TgHQHwF6cerJ/BB4jZrPhrmTZ8Pyp92OS6VlmPQmA3bvdCs+YyrD9/i/wV OSDg== X-Gm-Message-State: ACgBeo3iOuNDWQIXF45/OPkF7pIGb31WiT86oObMRx/dWc47yCkBfmJh P2dkJ9cQdYkW8T+g6l7RJkiQjza3lzg= X-Google-Smtp-Source: AA6agR6h2oZdzB6R8jI8Wgh9FvqE2HYjSG4rGjg/Hz+9VrQhAi7ee+fdgxOFxxEWWBciwEmO+Ft1LQ== X-Received: by 2002:a65:4202:0:b0:42b:d734:51e2 with SMTP id c2-20020a654202000000b0042bd73451e2mr4054995pgq.621.1662568524751; Wed, 07 Sep 2022 09:35:24 -0700 (PDT) Received: from devut-HP-Laptop-14q-cs0xxx.. ([2404:bd00:3:dfe3:188b:9ab7:b142:d552]) by smtp.gmail.com with ESMTPSA id x63-20020a626342000000b0052c849d0886sm12730439pfb.86.2022.09.07.09.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 09:35:24 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Sep 2022 22:05:04 +0530 Message-Id: <20220907163504.209658-1-utkarsh02t@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/1] qcam: Fix crash when switching from non existant camera 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: , X-Patchwork-Original-From: Utkarsh Tiwari via libcamera-devel From: Utkarsh Tiwari Reply-To: Utkarsh Tiwari Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When switching to different camera we try to release the camera previously used. But if that camera has been unplugged, then its instance would have been destroyed. Accessing it leads to seg fault. Fix by checking camera_ to see if it exists. Bug: https://bugs.libcamera.org/show_bug.cgi?id=147 Signed-off-by: Utkarsh Tiwari Reviewed-by: Laurent Pinchart Tested-by: Kieran Bingham Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/qcam/main_window.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 6fe36168..e0e5092e 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -284,7 +284,9 @@ void MainWindow::switchCamera() */ startStopAction_->setChecked(false); - camera_->release(); + if (camera_) + camera_->release(); + camera_ = cam; startStopAction_->setChecked(true);