From patchwork Wed Nov 8 23:52:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 5941 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp1370050jah; Wed, 8 Nov 2017 15:53:00 -0800 (PST) X-Google-Smtp-Source: ABhQp+TzJ0y7PrwNC2SztGM/UXc8pl7qTJ212f/MM7Z3JeuEQu5he/C5WiDmEKabSoNjPaaIhb1v X-Received: by 10.223.185.35 with SMTP id k32mr1881713wrf.50.1510185180770; Wed, 08 Nov 2017 15:53:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510185180; cv=none; d=google.com; s=arc-20160816; b=StfL+5INuE782AIgONqoE35iUhhgfr6a8AgCN1aymq1HC//lGQxgsMztzLoYeJejbh Mw6Os/y4jMn2hfiWDqfFwbCSHLOMS4yV8lumX5gnHVQMzSz9FTV9zeUxS4Q9kmMJ+mfD ryeTIMxhTTpMdluzHlvBbUh7Enm3oEMYgA3ZBXFy+TPLwjP7TA8ziya70HAYFp2Rr1Vi IhrBRZKTqkMtIC2r+wAr70YO0ewKMJDY5vUtIpn1Qnpjt8e6xhyCXTlYb0WCDK9KUbl3 QsmuZ4oABmngqewOuB3curOu82sDHxkybfvpFAvfR/pqO8D3qCQI+WMal7+wgsZXuCmZ z2ig== 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:feedback-id:message-id:date:to:from :delivered-to:arc-authentication-results; bh=cuaC0T2TDsJ7G7Fea7vPwmRY0ep3rC2srPcI+2b/xEs=; b=oxXMFRhyABlpxgnJFs+G4ytGx1mNqQMvkRZRq9SMPSeGK0cmHOD9FGh91p1aKBuuVR saj0vcEiBg99onCRGHq2anBQEK5Wp0ac1bs/sLMZu3q7J7FyEeAMPpYOgmDS98hriTa2 aHV6XB3U9UXuoYhUzBtA6yMhm2ymeRIHNa+1XDMVvKAZ6z/4wy9dTzk1uYEW9GL5DZ50 GdDHzA8RFIukKck0IMT3bVBzImRlyHtju1O7qsH61rm1uvp6qLr0eET3KH0eb4nZqL2u FCNEJW0XK464Yn56buy5NXpsFxNPSrtCrHRV7epW0PyCq6+EUcmdm7LhDDaK6FCj14ZC lKBQ== ARC-Authentication-Results: i=1; mx.google.com; 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 n8si4524963wmh.218.2017.11.08.15.52.59; Wed, 08 Nov 2017 15:53:00 -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; 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 959C5689B08; Thu, 9 Nov 2017 01:52:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau2.qq.com (smtpbgau2.qq.com [54.206.34.216]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C394E688323 for ; Thu, 9 Nov 2017 01:52:38 +0200 (EET) X-QQ-mid: bizesmtp3t1510185147t9w19mbho Received: from localhost (unknown [123.115.195.7]) by esmtp4.qq.com (ESMTP) with id ; Thu, 09 Nov 2017 07:52:25 +0800 (CST) X-QQ-SSF: 01100000004000F0FI70B00A0000000 X-QQ-FEAT: 6zzC9GfgSo4I+tgQUgHkFl87GuJ5j8Ifj6rV3g8cu215Zle+ZBFGIYViA3Epy R9kKEfkhn59uLAibAhNuehW0nFlZVGKgpCdZx3E+g0WlKqvxr2whIVy3JWOxr6gLRZLC//9 hp0LtzEHlJ6AwRmwZmLzidGKeww5HgBukQxcCMf2UCuEyzuQgL1PSPk/DIC5M9XrL7X5/hn tiM6bKhGYlTjHf8qxuc0CdkoK+vroVUM2/CYc+VJVf0D2w5Etq93qu/Ex5P9K7uo24h5+MK LdOXcTY5IwjRjPUG1qAyV2FBc= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Nov 2017 07:52:23 +0800 Message-Id: <20171108235223.67654-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.11.0 (Apple Git-81) X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/dashdec: fix memleak of rep_dest->parent null 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: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" fix ticket id: #6820 use the current DASHContext for the rep_dest Signed-off-by: Steven Liu --- libavformat/dashdec.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index f63f1fffbd..0f5f91c6b5 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1079,9 +1079,8 @@ static int64_t calc_min_seg_no(AVFormatContext *s, struct representation *pls) return num; } -static int64_t calc_max_seg_no(struct representation *pls) +static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c) { - DASHContext *c = pls->parent->priv_data; int64_t num = 0; if (pls->n_fragments) { @@ -1101,21 +1100,21 @@ static int64_t calc_max_seg_no(struct representation *pls) return num; } -static void move_timelines(struct representation *rep_src, struct representation *rep_dest) +static void move_timelines(struct representation *rep_src, struct representation *rep_dest, DASHContext *c) { if (rep_dest && rep_src ) { free_timelines_list(rep_dest); rep_dest->timelines = rep_src->timelines; rep_dest->n_timelines = rep_src->n_timelines; rep_dest->first_seq_no = rep_src->first_seq_no; - rep_dest->last_seq_no = calc_max_seg_no(rep_dest); + rep_dest->last_seq_no = calc_max_seg_no(rep_dest, c); rep_src->timelines = NULL; rep_src->n_timelines = 0; rep_dest->cur_seq_no = rep_src->cur_seq_no; } } -static void move_segments(struct representation *rep_src, struct representation *rep_dest) +static void move_segments(struct representation *rep_src, struct representation *rep_dest, DASHContext *c) { if (rep_dest && rep_src ) { free_fragment_list(rep_dest); @@ -1126,7 +1125,7 @@ static void move_segments(struct representation *rep_src, struct representation rep_dest->fragments = rep_src->fragments; rep_dest->n_fragments = rep_src->n_fragments; rep_dest->parent = rep_src->parent; - rep_dest->last_seq_no = calc_max_seg_no(rep_dest); + rep_dest->last_seq_no = calc_max_seg_no(rep_dest, c); rep_src->fragments = NULL; rep_src->n_fragments = 0; } @@ -1163,21 +1162,21 @@ static int refresh_manifest(AVFormatContext *s) if (cur_video && cur_video->timelines) { c->cur_video->cur_seq_no = calc_next_seg_no_from_timelines(c->cur_video, currentVideoTime * cur_video->fragment_timescale - 1); if (c->cur_video->cur_seq_no >= 0) { - move_timelines(c->cur_video, cur_video); + move_timelines(c->cur_video, cur_video, c); } } if (cur_audio && cur_audio->timelines) { c->cur_audio->cur_seq_no = calc_next_seg_no_from_timelines(c->cur_audio, currentAudioTime * cur_audio->fragment_timescale - 1); if (c->cur_audio->cur_seq_no >= 0) { - move_timelines(c->cur_audio, cur_audio); + move_timelines(c->cur_audio, cur_audio, c); } } } if (cur_video && cur_video->fragments) { - move_segments(c->cur_video, cur_video); + move_segments(c->cur_video, cur_video, c); } if (cur_audio && cur_audio->fragments) { - move_segments(c->cur_audio, cur_audio); + move_segments(c->cur_audio, cur_audio, c); } finish: @@ -1226,7 +1225,7 @@ static struct fragment *get_current_fragment(struct representation *pls) } if (c->is_live) { min_seq_no = calc_min_seg_no(pls->parent, pls); - max_seq_no = calc_max_seg_no(pls); + max_seq_no = calc_max_seg_no(pls, c); if (pls->timelines || pls->fragments) { refresh_manifest(pls->parent); @@ -1560,7 +1559,7 @@ static int open_demux_for_component(AVFormatContext *s, struct representation *p pls->parent = s; pls->cur_seq_no = calc_cur_seg_no(s, pls); - pls->last_seq_no = calc_max_seg_no(pls); + pls->last_seq_no = calc_max_seg_no(pls, s->priv_data); ret = reopen_demux_for_component(s, pls); if (ret < 0) {