diff mbox

[FFmpeg-devel] hls: fix leaking avio_opts on hls_read_header error

Message ID e500ec2f-ccf1-f641-ea90-d3aaa1f4eb3d@googlemail.com
State Accepted
Headers show

Commit Message

Andreas Cadhalpun Nov. 6, 2016, 11:11 p.m. UTC
Use the hls_close function to reduce code duplication.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavformat/hls.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

Comments

Michael Niedermayer Nov. 7, 2016, 3:20 p.m. UTC | #1
On Mon, Nov 07, 2016 at 12:11:25AM +0100, Andreas Cadhalpun wrote:
> Use the hls_close function to reduce code duplication.
> 
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavformat/hls.c | 30 ++++++++++++++----------------
>  1 file changed, 14 insertions(+), 16 deletions(-)

LGTM but please split into cosmetic move and bug fix

thx

[...]
Andreas Cadhalpun Nov. 7, 2016, 6:52 p.m. UTC | #2
On 07.11.2016 16:20, Michael Niedermayer wrote:
> On Mon, Nov 07, 2016 at 12:11:25AM +0100, Andreas Cadhalpun wrote:
>> Use the hls_close function to reduce code duplication.
>>
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
>> ---
>>  libavformat/hls.c | 30 ++++++++++++++----------------
>>  1 file changed, 14 insertions(+), 16 deletions(-)
> 
> LGTM but please split into cosmetic move and bug fix

Split and pushed.

Best regards,
Andreas
diff mbox

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 2bf86fa..3ae3c7c 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1593,6 +1593,19 @@  static void update_noheader_flag(AVFormatContext *s)
         s->ctx_flags &= ~AVFMTCTX_NOHEADER;
 }
 
+static int hls_close(AVFormatContext *s)
+{
+    HLSContext *c = s->priv_data;
+
+    free_playlist_list(c);
+    free_variant_list(c);
+    free_rendition_list(c);
+
+    av_dict_free(&c->avio_opts);
+
+    return 0;
+}
+
 static int hls_read_header(AVFormatContext *s)
 {
     void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
@@ -1794,9 +1807,7 @@  static int hls_read_header(AVFormatContext *s)
 
     return 0;
 fail:
-    free_playlist_list(c);
-    free_variant_list(c);
-    free_rendition_list(c);
+    hls_close(s);
     return ret;
 }
 
@@ -2013,19 +2024,6 @@  static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
     return AVERROR_EOF;
 }
 
-static int hls_close(AVFormatContext *s)
-{
-    HLSContext *c = s->priv_data;
-
-    free_playlist_list(c);
-    free_variant_list(c);
-    free_rendition_list(c);
-
-    av_dict_free(&c->avio_opts);
-
-    return 0;
-}
-
 static int hls_read_seek(AVFormatContext *s, int stream_index,
                                int64_t timestamp, int flags)
 {