From patchwork Sun Oct 26 11:46:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 5153821 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 381A2C11AC for ; Sun, 26 Oct 2014 11:47:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41B5220340 for ; Sun, 26 Oct 2014 11:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73C5B20303 for ; Sun, 26 Oct 2014 11:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751536AbaJZLrP (ORCPT ); Sun, 26 Oct 2014 07:47:15 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:58333 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751523AbaJZLrO (ORCPT ); Sun, 26 Oct 2014 07:47:14 -0400 Received: by mail-pa0-f46.google.com with SMTP id lf10so2061444pab.5 for ; Sun, 26 Oct 2014 04:47:14 -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=XRKytyCLD207Ay21XO2vb3b2g0kHlobO7ruum6JOHfU=; b=GrS4XT78XXvzxgBxcvS8MVB1Y97FaP4EdIUWUSRXZFZNqsR8yQob1w5JAXX63C3iP1 bo0K5EgTgaz+X4moXoB+HTGrNSMEEGdq1DT974ozuuDiNGHqbTuVN0LiE7AKnVFKYJWZ m99LPRASzIKtrzbZvbm77th29JquY8y2mFuPMmtZWk9yxZJh2D2oQXUfK9P7Qqmoxmkc sdkcIHncencUIktmhnpjQgj2CEN4hS6hT7J1bHAnA3Iin/HtMa9MQd4ZCS7aJFgUgL9A xUM6XobDFqMZz7N/4f2fLY7KNyVICqWMuuYYmqHk9VEkwfotG3krhW81qamYZe1VF9dh 0aXw== X-Received: by 10.68.110.161 with SMTP id ib1mr16812611pbb.109.1414324034278; Sun, 26 Oct 2014 04:47:14 -0700 (PDT) Received: from seabird.localdomain.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by mx.google.com with ESMTPSA id dp4sm8203581pbc.21.2014.10.26.04.47.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Oct 2014 04:47:13 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, Akihiro Tsukada Subject: [PATCH v2 1/7] v4l-utils/libdvbv5: fix auto generation of channel names Date: Sun, 26 Oct 2014 20:46:17 +0900 Message-Id: <1414323983-15996-2-git-send-email-tskd08@gmail.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1414323983-15996-1-git-send-email-tskd08@gmail.com> References: <1414323983-15996-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=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 when channel name was not available, it was generated from unset variables, and leaked memory. --- lib/libdvbv5/dvb-file.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c index 27d9a63..1ea14c4 100644 --- a/lib/libdvbv5/dvb-file.c +++ b/lib/libdvbv5/dvb-file.c @@ -1121,20 +1121,23 @@ static int get_program_and_store(struct dvb_v5_fe_parms_priv *parms, if (rc) dvb_logerr("Couldn't get frontend props"); } + 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) + freq = entry->props[j].u.data; + } if (!*channel) { - r = asprintf(&channel, "%.2fMHz#%d", freq/1000000., service_id); + free(channel); + r = asprintf(&channel, "%.2f%cHz#%d", freq / 1000000., + dvb_fe_is_satellite(parms->p.current_sys) ? 'G' : 'M', + 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) - freq = parms->dvb_prop[j].u.data; - } entry->n_props = parms->n_props; entry->channel = channel; @@ -1225,12 +1228,19 @@ int dvb_store_channel(struct dvb_file **dvb_file, continue; service_id = dvb_scan_handler->program[i].pat_pgm->service_id; + rc = asprintf(&channel, "#%d", service_id); + if (rc < 0) { + dvb_perror("asprintf"); + return rc; + } rc = get_program_and_store(parms, *dvb_file, dvb_scan_handler, service_id, channel, NULL, get_detected, get_nit); - if (rc < 0) + if (rc < 0) { + free(channel); return rc; + } } return 0;