diff mbox series

[FFmpeg-devel,07/10] avformat/hls: extract free_segment method

Message ID tencent_C37E2EAD8E38C9C029B40069B202F9698E0A@qq.com
State New
Headers show
Series [FFmpeg-devel,01/10] avformat/hls: fix repeated requests for media init section | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Zhao Zhili April 12, 2022, 8:15 a.m. UTC
---
 libavformat/hls.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3ed6007d0d..65937120d5 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -225,13 +225,18 @@  typedef struct HLSContext {
     HLSCryptoContext  crypto_ctx;
 } HLSContext;
 
+static void free_segment(struct segment *segment) {
+    av_free(segment->key);
+    av_free(segment->url);
+    av_free(segment);
+}
+
 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]);
+        free_segment(segments[i]);
+        segments[i] = NULL;
     }
 }