]> git.sesse.net Git - ffmpeg/commitdiff
lavf/hls: fix memory leak in error handling path for option tmp
authorJun Zhao <barryjzhao@tencent.com>
Fri, 13 Sep 2019 11:53:37 +0000 (19:53 +0800)
committerSteven Liu <lq@chinaffmpeg.org>
Sat, 14 Sep 2019 02:02:00 +0000 (10:02 +0800)
fix memory leak in error handling path for option tmp.

Reviewed-by: Steven Liu <lq@onvideo.cn>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
libavformat/hls.c

index bb07dcb96c693a54107f7f7881dac8945e2f4e5b..0611ddc6bb8b4019bf7d4c1572d6b6886e502e07 100644 (file)
@@ -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)