[FFmpeg-devel] avformat/dashdec: fix memleak of rep_dest->parent null

Submitted by Steven Liu on Nov. 8, 2017, 11:52 p.m.

Details

Message ID 20171108235223.67654-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu Nov. 8, 2017, 11:52 p.m.
fix ticket id: #6820
use the current DASHContext for the rep_dest

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/dashdec.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Comments

Steven Liu Nov. 9, 2017, 11:07 p.m.
2017-11-09 16:28 GMT+08:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> Hi!
>
>> Am 09.11.2017 um 00:52 schrieb Steven Liu <lq@chinaffmpeg.org>:
>>
>> fix ticket id: #6820
>
> I find the commit message misleading.
>
>> use the current DASHContext for the rep_dest
>
> This may be better imo.
Pushed and applied this suggestion.


Thanks
>
> Thank you, Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Patch hide | download patch | download mbox

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) {