[{"id":28333,"web_url":"https://patchwork.libcamera.org/comment/28333/","msgid":"<87a5qbo8b0.fsf@redhat.com>","date":"2023-12-15T14:21:39","subject":"Re: [libcamera-devel] [PATCH] Avoid segfault with bad configuration","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Pavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org> writes:\n\n> Without this patch, I get segfault instead of \"Failed to get default\n> stream configuration\" message.\n\nIt works for me, but ...\n\n> Signed-off-by: Pavel Machek <pavel@ucw.cz>\n>\n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index bdc7bfe5..8a315bfd 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -1138,6 +1138,8 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Span<const StreamRo\n>  \t */\n>  \tfor ([[maybe_unused]] StreamRole role : roles) {\n>  \t\tStreamConfiguration cfg{ StreamFormats{ formats } };\n> +\t\tif (!formats.begin()->first)\n> +\t\t\tcontinue;\n\n... shouldn't the condition be\n\n  if (formats.empty())\n\n?\n\nAnd couldn't the check be applied on the whole loop (which looks weird to me\nanyway and the preceding todo comment most likely applies)?\n\n>  \t\tcfg.pixelFormat = formats.begin()->first;\n>  \t\tcfg.size = formats.begin()->second[0].max;","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 93C02C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Dec 2023 14:21:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8639662B2E;\n\tFri, 15 Dec 2023 15:21:47 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BE5AF61D96\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Dec 2023 15:21:44 +0100 (CET)","from mail-ej1-f70.google.com (mail-ej1-f70.google.com\n\t[209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-198-_D7Z5oTEMFekUI5_-zZaoA-1; Fri, 15 Dec 2023 09:21:42 -0500","by mail-ej1-f70.google.com with SMTP id\n\ta640c23a62f3a-a1d38492da7so44956266b.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Dec 2023 06:21:42 -0800 (PST)","from nuthatch (ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tvq6-20020a170907a4c600b00a1d5444c2cdsm11016077ejc.140.2023.12.15.06.21.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 15 Dec 2023 06:21:39 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702650107;\n\tbh=hzDNwhXZx4xXcU8Psq7dRJMg4qSK+371hVXf1pIRYeE=;\n\th=To:In-Reply-To:References:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=CJsh1CvYuZWQXRs3QpI3Hc740rN9bbsuAkvcg33ASafyx3eJjehlbiEy9sr6KPvB7\n\tq7Jz4q4XJAUeT7au7tLwYLj0EJ9fwyNS+6Ggiyu//IX/4JmAxxis6JeBbUhxKuyPZl\n\tNlbp8BzQ6tLuM0kcNrbgq6NAaGMZz/SOty88YIO6B22YDAoHhMg4HqgCHwkxDhuMrM\n\tyytdAzvlp2fUG7E2+XB8648vhFXOk2f9g3e/LfI6FJ/JiMgdxkDZCrxcGjksiLGqZz\n\t7a2vJDptz7kEG2cY2wneFfdGulrEdTc/5F4n2pRCsCs2RTeVL5c4gplhNcRI9NzSHk\n\t45wXchU4+r19g==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1702650103;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=DrHzv+3bpQ2Lsk4imk7Kcds1E7emvc99xQ5svRWZA78=;\n\tb=PA1ItQoFP/L82F87K3VgVjzoA99gLWqNudQp5Gza5yRw/5YGRVQ713Py4Se3i7zxSJk2o4\n\tF3bDkv6CTbAOrswiJLoVlUXSjBF6NNsKauc2dP73Os7hjMfVHNGvBNMJQTeK4bdVLXpBcg\n\tlXjO02S2YgsviYAFubiDgNEir4I8ZNE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"PA1ItQoF\"; \n\tdkim-atps=neutral","X-MC-Unique":"_D7Z5oTEMFekUI5_-zZaoA-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1702650100; x=1703254900;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=DrHzv+3bpQ2Lsk4imk7Kcds1E7emvc99xQ5svRWZA78=;\n\tb=nq9D30tC1/Tg+Nomg8wu3vgMXms3tS1B1WzK0du1UtMq2X/ajN64OV5jH0Ncbydjdd\n\twldxIN6PAOh57vaJb2Kfh5xlKIehVnIufIV7Z2lAB9MPJlSnCeSgQO00q4d+CbVE1ltb\n\tItZnOa76uYBIZcaTIY8qyXikPRjKOdsAlzxBTevixGkEGOWdmzoTGS0AVQ+zcgWVMYN0\n\tp+kON58K1CbT15bdcN5969te3AQbj/bg1+E44rRa0x+cq3CKzDbj5ito1EIvrSraXPfD\n\tCMN/UKmi9pdNDwcntX2atgf2e8QZDqlf3MZzJCaE2Xp11CenKWLBeN2a3fTBfUYpdmS6\n\tcf1Q==","X-Gm-Message-State":"AOJu0YywN8V+pUz8poxBGXWYPzHW2ovyI85yzqKVPfO3+efDk33Syn27\n\tgl+PihDEOxZInRO1B2yjhvrlHqDZKGmgwxRvh5S0T84jXhL5pimki1CrMh/dE6BK8jD+046LJMk\n\tL/kpga+dJaQhS31Xt8GmypUIrM2iYCAeS96dU+UffEw==","X-Received":["by 2002:a17:907:3e8b:b0:a1d:5666:a7b3 with SMTP id\n\ths11-20020a1709073e8b00b00a1d5666a7b3mr3403229ejc.81.1702650100528; \n\tFri, 15 Dec 2023 06:21:40 -0800 (PST)","by 2002:a17:907:3e8b:b0:a1d:5666:a7b3 with SMTP id\n\ths11-20020a1709073e8b00b00a1d5666a7b3mr3403226ejc.81.1702650100276; \n\tFri, 15 Dec 2023 06:21:40 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IF5zkIJN6OHQidp9ln49AtOtONBANEP6Ssmb0EA5FnTbU6mE1A+OWU6u6B2mR9sLajWmoQtYw==","To":"libcamera-devel@lists.libcamera.org","In-Reply-To":"<ZXt0yJ2dqUIn6Ari@duo.ucw.cz> (Pavel Machek via\n\tlibcamera-devel's message of \"Thu, 14 Dec 2023 22:34:00 +0100\")","References":"<ZXt0yJ2dqUIn6Ari@duo.ucw.cz>","Date":"Fri, 15 Dec 2023 15:21:39 +0100","Message-ID":"<87a5qbo8b0.fsf@redhat.com>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","Subject":"Re: [libcamera-devel] [PATCH] Avoid segfault with bad configuration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Milan Zamazal via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"Pavel Machek <pavel@ucw.cz>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]