From patchwork Sat Jan 20 01:14:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan McGrath X-Patchwork-Id: 7353 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp178280jak; Fri, 19 Jan 2018 17:15:02 -0800 (PST) X-Google-Smtp-Source: AH8x225Fh4HrJ4oHwQAqXhx4gjOB2fNdCXdLuvRe3u22IGWgrfDKF30v6qYT6wvJR3OPajjQca7U X-Received: by 10.223.190.15 with SMTP id n15mr274621wrh.38.1516410902398; Fri, 19 Jan 2018 17:15:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516410902; cv=none; d=google.com; s=arc-20160816; b=KaCF9gGBPP9y9vJVlC/JqxI9sFU9JhlYy+h7a0OCmUmWCwvywhK9rGbNNNaz4FgE+n TdK4fTkoooSyZOBIyptSxJ2quBXv28q9UtkvxbffSI+X34xz6QhNWFaGPtor4buEDtgb DxabMerWXTzo9JOY2aSxOxxhOnDSNm72HYot03tlm7jzZl+jsswqVfdW2dCQHKlZhvyP 0L/Tb0pNjOI3T3knIoXjx2y/+Mv2aOtrReIGGZDuimPfjNsbN+RJtMdYmmRmnLV5hGzy KMsoErWY2h52zIpZ/naSkpvIOV5nFtcbMAaJ+i7Zlfo0otUu+4+lPzN6nQ3DRzei28SV IMQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=h76MpMmYY1wfxSFpZuJihQQPpVMw8A2rkBJnI/mWAkE=; b=opzFI3G3foTJy9DZc4XO7CkUWcTEupTsZEYDEnrTRVNMg85cMGxUZo2x2x/xoCGzIc qeDNCMg3qDE9rcAGbnq56WKkT6XGVUySsA8lNUwAF+Mxmgr3jxjupeTYJOAX6FK0BydV j6sV2mTZ7DwjCauRN1aP9b07JzI8P4Ncmd3W+8hGmhH2e8h8m3L9WAsW5PmXrJIZxcf5 l+fghORoCVpTuGNwrhIiqM5MSr0pkT7EAS/tnkdKkKKBSAGv7/dpHCdy6emlZ8L39AIL loOgAfO3bBj31C5uHcSk7ALIRGNrhG9eS0EzGcxqNegCdxtRA5V8ejSsSZ4bEeNE8z3Y g0tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@hermana.com.au header.s=2016 header.b=Vzv9yGx1; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 92si8674425wrf.358.2018.01.19.17.15.01; Fri, 19 Jan 2018 17:15:02 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@hermana.com.au header.s=2016 header.b=Vzv9yGx1; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C389E68832C; Sat, 20 Jan 2018 03:14:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.hermana.com.au (ec2-13-54-119-68.ap-southeast-2.compute.amazonaws.com [13.54.119.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 088766882FB for ; Sat, 20 Jan 2018 03:14:52 +0200 (EET) Received: from brendan-desktop.localdomain (2001-44b8-412c-1c00-3def-8e15-6d55-724d.static.ipv6.internode.on.net [IPv6:2001:44b8:412c:1c00:3def:8e15:6d55:724d]) by mail.hermana.com.au (Postfix) with ESMTPSA id 0780845; Sat, 20 Jan 2018 01:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hermana.com.au; s=2016; t=1516410890; bh=n3Qgm3fhN9/QAoThcX4Zz5h0u2+vpzw/FPBSAp6d6yg=; h=From:To:Cc:Subject:Date:From; b=Vzv9yGx1pOpyzMmk4d716E7Vn26AN0oO+k+uEdRE5RFmYf+FfPhVki1JUyTEzvJti 63aBHXN7yOG/S4qyJWmxcsxsv4DgKbiqV8dLz/M675NmGovLc1MFOdCmbwvrcxQhlM xamaffunVNoGOiQZ95fWjAnDYVhlRY9tT5Z2u2g0= From: Brendan McGrath To: ffmpeg-devel@ffmpeg.org, Steven Liu , Michael Niedermayer Date: Sat, 20 Jan 2018 12:14:35 +1100 Message-Id: <1516410875-17541-1-git-send-email-redmcg@redmandi.dyndns.org> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCHv2] dashdec: Only free url string if being reused X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Brendan McGrath MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If no representation bandwidth value is set, the url value returned by get_content_url is corrupt (as it has been freed). This change ensures the url string is not freed unless it is about to be reused Signed-off-by: Brendan McGrath --- Changes since v1: - removed the unneeded 'if' statement (as pointed out by Michael Niedermayer - added comment to make it clear why the av_free was required libavformat/dashdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 2492f1d..6380318 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -482,9 +482,10 @@ static char *get_content_url(xmlNodePtr *baseurl_nodes, return NULL; } av_strlcpy(tmp_str, url, sizeof(tmp_str)); - av_free(url); } if (rep_bandwidth_val && tmp_str[0] != '\0') { + // free any previously assigned url before reassigning + av_free(url); url = av_strireplace(tmp_str, "$Bandwidth$", (const char*)rep_bandwidth_val); if (!url) { return NULL;