From patchwork Sat Sep 19 16:36:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22502 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 452AF4496B7 for ; Sat, 19 Sep 2020 19:40:24 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C505D68B965; Sat, 19 Sep 2020 19:37:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 89D7F68B71E for ; Sat, 19 Sep 2020 19:37:36 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id e11so8747338wme.0 for ; Sat, 19 Sep 2020 09:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0fMb+cExjxKvNrQGHUgmZnINmBqgYOMHM2NL5nOb/vU=; b=OKqVfWRwpjWSir/l4586tNgtuFKRdscH12ySXOS1ux5EFrZll3TrAFENsVu5ijaFlh +Pu3ZuP3FRAfbpriTbyRAeHSLNdffgj5csl36R/DiWy5g2tXeiVRU1gOx5zNKMWF5XXF jux0gD1lMiOlh4X+BjMlsvc7G/JoPjDDWbwDLKAQxi3Y+oFKGePv0BMmTiKAFI/sp2wE VfzhbcW67QNJ5lm/t4F5upQfGzR3TgUwlFA68xqcx3GzMMBDpyGfaolSzLg5XEnxiYKO eHrt146KDPR7YDyZ2bipNHHYoqQNE0J4AfMuSNOpxHqtbi3lBLby8k8vJc+hxMFhTHkg 9I7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0fMb+cExjxKvNrQGHUgmZnINmBqgYOMHM2NL5nOb/vU=; b=T+kGeqLH7q3vE2hBoxWqpSyAOZNwjRr5N3huWBDS9+E2rvEhvO8a7HUlhXjpAilobG sKjw/RSW4wnzEbkXXak++pDMVkbcTN9oiUh11Xn6B3gs47ZC2Xu0JVPDPuYyAFsVvd8Y ED+/ArJEaRzcjfPZxKyA4gyIDafWkzkEDxQrpiCrLyP2LinW1QEgpJR7mhk26O9UYN+P 1XN8dT+zF/FMJygZioXZcUkT2AsfCjqsHJK+9/2uPVOps2VjWZhBzOJLWFWAxoULHD0g mu4oTNVHyLIxKufuUTx9DUF/sWEzWBpYUNu3PvevfSpCt9Mlz4FCleybWOKLoh33FpSd jfAw== X-Gm-Message-State: AOAM531eau3TLxXqVu/Jq2nUObizcGkkGszQnLjaup9h2WsQM1I94li8 v+XBbF443/XonQ6eA/fXDN0UmdLfdbs= X-Google-Smtp-Source: ABdhPJyuRX/XkZ3J4OIPWrsFfRD28XMzKYt2q/LDQ3jFwY0zf6E/VFpZvB8i+6xtzOCyS2bU6MynNg== X-Received: by 2002:a1c:e108:: with SMTP id y8mr21291258wmg.179.1600533455401; Sat, 19 Sep 2020 09:37:35 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id d5sm12451137wrb.28.2020.09.19.09.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 09:37:34 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 19 Sep 2020 18:36:10 +0200 Message-Id: <20200919163610.1099233-21-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200919163610.1099233-1-andreas.rheinhardt@gmail.com> References: <20200919163610.1099233-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/21] avformat/dashdec: Avoid duplicating string 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- There is still stuff left to fix in this demuxer after this patchset: 1. resolve_content_path() is in bad shape; i.e. it can try to read str[-1]. 2. One can get a crash in get_current_fragment() (or rather in ff_dash_fill_tmpl_params()) when one has a representation without fragment and without fragment/url template. 3. When one has a mismatch between old and new manifests in refresh_manifest(), the old representations leak. One could fix this by freeing the new representations and restoring the old ones, but this feels wrong; freeing the old ones is not possible, because refresh_manifests() is called indirectly by the read_packet function of an AVFormatContext associated with an old representation, so freeing the old representations would free the AVIOContext from within its read_packet function. This would lead to use-after-frees. libavformat/dashdec.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index be67192b14..747b4e92e3 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1183,7 +1183,6 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) DASHContext *c = s->priv_data; int ret = 0; int close_in = 0; - uint8_t *new_url = NULL; int64_t filesize = 0; AVBPrint buf; AVDictionary *opts = NULL; @@ -1212,11 +1211,8 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) return ret; } - if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, &new_url) >= 0) { - c->base_url = av_strdup(new_url); - } else { + if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, (uint8_t**)&c->base_url) < 0) c->base_url = av_strdup(url); - } filesize = avio_size(in); filesize = filesize > 0 ? filesize : DEFAULT_MANIFEST_SIZE; @@ -1359,7 +1355,6 @@ cleanup: xmlFreeNode(mpd_baseurl_node); } - av_free(new_url); av_bprint_finalize(&buf, NULL); if (close_in) { avio_close(in);