diff mbox

[FFmpeg-devel,V1,4/4] lavf/hls: fix memory leak in error handling path for option tmp

Message ID 1568375617-19090-4-git-send-email-mypopydev@gmail.com
State Accepted
Commit 0c5726a332734d18821e03779f94d1af8e251641
Headers show

Commit Message

Jun Zhao Sept. 13, 2019, 11:53 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

fix memory leak in error handling path for option tmp.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/hls.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index bb07dcb..0611ddc 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -620,9 +620,6 @@  static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
     int ret;
     int is_http = 0;
 
-    av_dict_copy(&tmp, opts, 0);
-    av_dict_copy(&tmp, opts2, 0);
-
     if (av_strstart(url, "crypto", NULL)) {
         if (url[6] == '+' || url[6] == ':')
             proto_name = avio_find_protocol_name(url + 7);
@@ -655,9 +652,13 @@  static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
     else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
         return AVERROR_INVALIDDATA;
 
+    av_dict_copy(&tmp, opts, 0);
+    av_dict_copy(&tmp, opts2, 0);
+
     if (is_http && c->http_persistent && *pb) {
         ret = open_url_keepalive(c->ctx, pb, url);
         if (ret == AVERROR_EXIT) {
+            av_dict_free(&tmp);
             return ret;
         } else if (ret < 0) {
             if (ret != AVERROR_EOF)