diff mbox

[FFmpeg-devel] lavf/dashdec: Fix several memleaks

Message ID CAB0OVGpHMCtL5b-s3nevT8112JNe+YYGEVsDw0aQ3Vn_2wVKFg@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Nov. 8, 2017, 9:46 p.m. UTC
Hi!

Attached patch fixes several memleaks found testing ticket #6820 (I
cannot reproduce the crash).

Please comment, Carl Eugen

Comments

Michael Niedermayer Nov. 9, 2017, 6:55 p.m. UTC | #1
On Wed, Nov 08, 2017 at 10:46:27PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes several memleaks found testing ticket #6820 (I
> cannot reproduce the crash).
> 
> Please comment, Carl Eugen

>  dashdec.c |   22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 557d3b077beb6b9d73ed401761a318ebd5079c3d  0001-lavf-dashdec-Fix-several-memleaks.patch
> From 915eae44e2f9bd7fb5ae78aa697338f348db3e08 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Wed, 8 Nov 2017 22:44:06 +0100
> Subject: [PATCH] lavf/dashdec: Fix several memleaks.

probably ok but iam not maintainer of this

[...]
Steven Liu Nov. 9, 2017, 11:06 p.m. UTC | #2
2017-11-10 2:55 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Wed, Nov 08, 2017 at 10:46:27PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes several memleaks found testing ticket #6820 (I
>> cannot reproduce the crash).
>>
>> Please comment, Carl Eugen
>
>>  dashdec.c |   22 +++++++++++++---------
>>  1 file changed, 13 insertions(+), 9 deletions(-)
>> 557d3b077beb6b9d73ed401761a318ebd5079c3d  0001-lavf-dashdec-Fix-several-memleaks.patch
>> From 915eae44e2f9bd7fb5ae78aa697338f348db3e08 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> Date: Wed, 8 Nov 2017 22:44:06 +0100
>> Subject: [PATCH] lavf/dashdec: Fix several memleaks.
>
> probably ok but iam not maintainer of this

Tested passed.

Pushed

Thanks
>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Complexity theory is the science of finding the exact solution to an
> approximation. Benchmarking OTOH is finding an approximation of the exact
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

From 915eae44e2f9bd7fb5ae78aa697338f348db3e08 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Wed, 8 Nov 2017 22:44:06 +0100
Subject: [PATCH] lavf/dashdec: Fix several memleaks.

---
 libavformat/dashdec.c |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index f63f1ff..bc20fb7 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -328,17 +328,17 @@  static void free_representation(struct representation *pls)
     }
 
     av_freep(&pls->url_template);
-    av_freep(pls);
+    av_freep(&pls);
 }
 
-static void set_httpheader_options(DASHContext *c, AVDictionary *opts)
+static void set_httpheader_options(DASHContext *c, AVDictionary **opts)
 {
     // broker prior HTTP options that should be consistent across requests
-    av_dict_set(&opts, "user-agent", c->user_agent, 0);
-    av_dict_set(&opts, "cookies", c->cookies, 0);
-    av_dict_set(&opts, "headers", c->headers, 0);
+    av_dict_set(opts, "user-agent", c->user_agent, 0);
+    av_dict_set(opts, "cookies", c->cookies, 0);
+    av_dict_set(opts, "headers", c->headers, 0);
     if (c->is_live) {
-        av_dict_set(&opts, "seekable", "0", 0);
+        av_dict_set(opts, "seekable", "0", 0);
     }
 }
 static void update_options(char **dest, const char *name, void *src)
@@ -885,7 +885,7 @@  static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)
     if (!in) {
         close_in = 1;
 
-        set_httpheader_options(c, opts);
+        set_httpheader_options(c, &opts);
         ret = avio_open2(&in, url, AVIO_FLAG_READ, c->interrupt_callback, &opts);
         av_dict_free(&opts);
         if (ret < 0)
@@ -1302,7 +1302,7 @@  static int open_input(DASHContext *c, struct representation *pls, struct fragmen
     char url[MAX_URL_SIZE];
     int ret;
 
-    set_httpheader_options(c, opts);
+    set_httpheader_options(c, &opts);
     if (seg->size >= 0) {
         /* try to restrict the HTTP request to the part we want
          * (if this is in fact a HTTP request) */
@@ -1466,8 +1466,12 @@  static int save_avio_options(AVFormatContext *s)
         if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
             if (buf[0] != '\0') {
                 ret = av_dict_set(&c->avio_opts, *opt, buf, AV_DICT_DONT_STRDUP_VAL);
-                if (ret < 0)
+                if (ret < 0) {
+                    av_freep(&buf);
                     return ret;
+                }
+            } else {
+                av_freep(&buf);
             }
         }
         opt++;
-- 
1.7.10.4