From patchwork Wed Oct 8 12:09:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 5053361 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 34D739F349 for ; Wed, 8 Oct 2014 12:10:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F15E201C8 for ; Wed, 8 Oct 2014 12:10:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D9412017D for ; Wed, 8 Oct 2014 12:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756271AbaJHMKN (ORCPT ); Wed, 8 Oct 2014 08:10:13 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:62860 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755174AbaJHMKM (ORCPT ); Wed, 8 Oct 2014 08:10:12 -0400 Received: by mail-pa0-f54.google.com with SMTP id ey11so9044071pad.13 for ; Wed, 08 Oct 2014 05:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gOpVLTNj2shmALP5WDXebY/3S8y/R9uhtNgG2AzrQzo=; b=WbDAuecMaDee4CXRqADZdIOS3pLcW1ECSqdbUjBwlO88tXyvXYPQ7ftNFdLrW9hwDU pu5XOONQnIzPFPeEXykbLV0ja3jvRW423UsZbZZSyPSfRC4xGdrd1ViB97LBVNscY8hU ji2DC5A7kQEKalJAzAK7v4GshSNVxLkpC751IKrlCgGzyMSgWBOMQj2cYmwJ3kBATr0r 9G2qMukc/i2IfGQ1J+VKrGO7j232pmSzn1yALeMoTNHUQl1hwLlTEIWeQ+U0bWdcCr4C bJ/BMEgYY1gorUrrZCOqpoyvly1qd7V1/LG9dkVdeIJ8SBQMhs7tMKkp9ighMxkkaFdV v4kw== X-Received: by 10.70.87.233 with SMTP id bb9mr10289882pdb.89.1412770212076; Wed, 08 Oct 2014 05:10:12 -0700 (PDT) Received: from seabird.localdomain.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by mx.google.com with ESMTPSA id g1sm16426666pdh.12.2014.10.08.05.10.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Oct 2014 05:10:11 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com Subject: [PATCH 1/4] v4l-utils/libdvbv5: avoid crash when failed to get a channel name Date: Wed, 8 Oct 2014 21:09:38 +0900 Message-Id: <1412770181-5420-2-git-send-email-tskd08@gmail.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1412770181-5420-1-git-send-email-tskd08@gmail.com> References: <1412770181-5420-1-git-send-email-tskd08@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Akihiro Tsukada Signed-off-by: Akihiro Tsukada --- lib/libdvbv5/dvb-file.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c index 27d9a63..bcb1762 100644 --- a/lib/libdvbv5/dvb-file.c +++ b/lib/libdvbv5/dvb-file.c @@ -1121,20 +1121,21 @@ static int get_program_and_store(struct dvb_v5_fe_parms_priv *parms, if (rc) dvb_logerr("Couldn't get frontend props"); } - if (!*channel) { - r = asprintf(&channel, "%.2fMHz#%d", freq/1000000., service_id); - if (r < 0) - dvb_perror("asprintf"); - if (parms->p.verbose) - dvb_log("Storing as: '%s'", channel); - } for (j = 0; j < parms->n_props; j++) { entry->props[j].cmd = parms->dvb_prop[j].cmd; entry->props[j].u.data = parms->dvb_prop[j].u.data; - if (!*channel && entry->props[j].cmd == DTV_FREQUENCY) + if ((!channel || !*channel) && + entry->props[j].cmd == DTV_FREQUENCY) freq = parms->dvb_prop[j].u.data; } + if (!channel || !*channel) { + r = asprintf(&channel, "%.2fMHz#%d", freq/1000000., service_id); + if (r < 0) + dvb_perror("asprintf"); + if (parms->p.verbose) + dvb_log("Storing as: '%s'", channel); + } entry->n_props = parms->n_props; entry->channel = channel;