[FFmpeg-devel] avformat/hls.c: Properly free prev_segments dynarray after playlist parsing

Submitted by Valery Kot on Dec. 24, 2018, 9:24 a.m.

Details

Message ID CAGTf1MnJQY7mv3N19MFn7MMz=uA-r6TkRNQrw5_kTe0ZzHminQ@mail.gmail.com
State New
Headers show

Commit Message

Valery Kot Dec. 24, 2018, 9:24 a.m.
Updated commit message for hls.c memory leak fix
From 0bb8c4a17f9de7167f3aafc59fc309f581e00e0b Mon Sep 17 00:00:00 2001
From: vkot <valery.kot@4cinsights.com>
Date: Mon, 24 Dec 2018 10:19:55 +0100
Subject: [PATCH] avformat/hls.c: Properly free prev_segments dynarray after
 playlist parsing

---
 libavformat/hls.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Steven Liu Dec. 24, 2018, 10:25 a.m.
> 在 2018年12月24日,下午5:24,Valery Kot <valery.kot@gmail.com> 写道:
> 
> Updated commit message for hls.c memory leak fix
> <0001-avformat-hls.c-Properly-free-prev_segments-dynarray-.txt>_______________________________________________

Looking at the free_segment_dynarray:

static void free_segment_dynarray(struct segment **segments, int n_segments)
{
    int i;
    for (i = 0; i < n_segments; i++) {
        av_freep(&segments[i]->key);
        av_freep(&segments[i]->url);
        av_freep(&segments[i]);
    }
}

perhaps the segments have been free?

Thanks
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Steven Liu Dec. 24, 2018, 10:59 a.m.
> 在 2018年12月24日,下午6:25,Liu Steven <lq@chinaffmpeg.org> 写道:
> 
> 
> 
>> 在 2018年12月24日,下午5:24,Valery Kot <valery.kot@gmail.com> 写道:
>> 
>> Updated commit message for hls.c memory leak fix
>> <0001-avformat-hls.c-Properly-free-prev_segments-dynarray-.txt>_______________________________________________
> 
> Looking at the free_segment_dynarray:
> 
> static void free_segment_dynarray(struct segment **segments, int n_segments)
> {
>    int i;
>    for (i = 0; i < n_segments; i++) {
>        av_freep(&segments[i]->key);
>        av_freep(&segments[i]->url);
>        av_freep(&segments[i]);
>    }
> }
> 
> perhaps the segments have been free?
Ah, ok, i see, you are right.

Patch will push after 24 hours if there have no objections.

Thanks

Steven
> 
> Thanks
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Steven Liu Dec. 26, 2018, 11:22 a.m.
> 在 2018年12月24日,下午5:24,Valery Kot <valery.kot@gmail.com> 写道:
> 
> Updated commit message for hls.c memory leak fix
> <0001-avformat-hls.c-Properly-free-prev_segments-dynarray-.txt>_______________________________________________

Pushed

Thanks
Steven
> 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/hls.c b/libavformat/hls.c
index 8ad08baaed..63e1abe789 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -931,6 +931,7 @@  static int parse_playlist(HLSContext *c, const char *url,
                    prev_start_seq_no, pls->start_seq_no);
         }
         free_segment_dynarray(prev_segments, prev_n_segments);
+        av_freep(&prev_segments);
     }
     if (pls)
         pls->last_load_time = av_gettime_relative();