]> git.sesse.net Git - ffmpeg/commitdiff
avformat/dashdec: Fix leak of AVDictionary on error
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 7 Sep 2020 18:36:25 +0000 (20:36 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 21 Sep 2020 02:31:40 +0000 (04:31 +0200)
Just postpone the allocation of the dict until it is really needed
(after the checks that can fail).

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/dashdec.c

index 3b83075e7ad85ce23082a171bc847b67a09896ac..ee40f2aa0c5accf263382d7a271171ae78a9072b 100644 (file)
@@ -407,9 +407,6 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
     const char *proto_name = NULL;
     int ret;
 
-    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);
@@ -443,6 +440,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
         return AVERROR_INVALIDDATA;
 
     av_freep(pb);
+    av_dict_copy(&tmp, opts, 0);
+    av_dict_copy(&tmp, opts2, 0);
     ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp);
     if (ret >= 0) {
         // update cookies on http response with setcookies.