diff mbox

[FFmpeg-devel,4/7] avformat/icecast: Use AV_DICT_DONT_STRDUP_VAL to save an av_strdup

Message ID 20191110040733.11755-3-andreas.rheinhardt@gmail.com
State Accepted
Commit 15345881e772571010a54c98ec1ada370c6bad9a
Headers show

Commit Message

Andreas Rheinhardt Nov. 10, 2019, 4:07 a.m. UTC
This will probably also fix CID 1452559, a false positive where Coverity
claims a double-free occurs, because it thinks that av_dict_set() frees
its key and value arguments even when the AV_DICT_DONT_STRDUP_* flags
aren't used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/icecast.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Marvin Scholz Dec. 20, 2019, 8:32 a.m. UTC | #1
On 10 Nov 2019, at 5:07, Andreas Rheinhardt wrote:

> This will probably also fix CID 1452559, a false positive where 
> Coverity
> claims a double-free occurs, because it thinks that av_dict_set() 
> frees
> its key and value arguments even when the AV_DICT_DONT_STRDUP_* flags
> aren't used.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/icecast.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/libavformat/icecast.c b/libavformat/icecast.c
> index 052cd37f3e..7d8f92fe73 100644
> --- a/libavformat/icecast.c
> +++ b/libavformat/icecast.c
> @@ -114,7 +114,7 @@ static int icecast_open(URLContext *h, const char 
> *uri, int flags)
>      // Set options
>      av_dict_set(&opt_dict, "method", s->legacy_icecast ? "SOURCE" : 
> "PUT", 0);
>      av_dict_set(&opt_dict, "auth_type", "basic", 0);
> -    av_dict_set(&opt_dict, "headers", headers, 0);
> +    av_dict_set(&opt_dict, "headers", headers, 
> AV_DICT_DONT_STRDUP_VAL);
>      av_dict_set(&opt_dict, "chunked_post", "0", 0);
>      av_dict_set(&opt_dict, "send_expect_100", s->legacy_icecast ? 
> "-1" : "1", 0);
>      if (NOT_EMPTY(s->content_type))
> @@ -170,7 +170,6 @@ static int icecast_open(URLContext *h, const char 
> *uri, int flags)
>
>  cleanup:
>      av_freep(&user);
> -    av_freep(&headers);
>      av_dict_free(&opt_dict);
>
>      return ret;
> -- 
> 2.20.1
>
>

Thanks for the patch, LGTM.
(I can’t push it though, so someone else needs to approve too and push 
this)
Michael Niedermayer Dec. 21, 2019, 2:03 p.m. UTC | #2
On Fri, Dec 20, 2019 at 09:32:34AM +0100, Marvin Scholz wrote:
> On 10 Nov 2019, at 5:07, Andreas Rheinhardt wrote:
> 
> >This will probably also fix CID 1452559, a false positive where Coverity
> >claims a double-free occurs, because it thinks that av_dict_set() frees
> >its key and value arguments even when the AV_DICT_DONT_STRDUP_* flags
> >aren't used.
> >
> >Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> >---
> > libavformat/icecast.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> >diff --git a/libavformat/icecast.c b/libavformat/icecast.c
> >index 052cd37f3e..7d8f92fe73 100644
> >--- a/libavformat/icecast.c
> >+++ b/libavformat/icecast.c
> >@@ -114,7 +114,7 @@ static int icecast_open(URLContext *h, const char
> >*uri, int flags)
> >     // Set options
> >     av_dict_set(&opt_dict, "method", s->legacy_icecast ? "SOURCE" :
> >"PUT", 0);
> >     av_dict_set(&opt_dict, "auth_type", "basic", 0);
> >-    av_dict_set(&opt_dict, "headers", headers, 0);
> >+    av_dict_set(&opt_dict, "headers", headers, AV_DICT_DONT_STRDUP_VAL);
> >     av_dict_set(&opt_dict, "chunked_post", "0", 0);
> >     av_dict_set(&opt_dict, "send_expect_100", s->legacy_icecast ? "-1" :
> >"1", 0);
> >     if (NOT_EMPTY(s->content_type))
> >@@ -170,7 +170,6 @@ static int icecast_open(URLContext *h, const char
> >*uri, int flags)
> >
> > cleanup:
> >     av_freep(&user);
> >-    av_freep(&headers);
> >     av_dict_free(&opt_dict);
> >
> >     return ret;
> >-- 
> >2.20.1
> >
> >
> 
> Thanks for the patch, LGTM.

will apply 

thx

> (I can’t push it though, so someone else needs to approve too and push this)
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/libavformat/icecast.c b/libavformat/icecast.c
index 052cd37f3e..7d8f92fe73 100644
--- a/libavformat/icecast.c
+++ b/libavformat/icecast.c
@@ -114,7 +114,7 @@  static int icecast_open(URLContext *h, const char *uri, int flags)
     // Set options
     av_dict_set(&opt_dict, "method", s->legacy_icecast ? "SOURCE" : "PUT", 0);
     av_dict_set(&opt_dict, "auth_type", "basic", 0);
-    av_dict_set(&opt_dict, "headers", headers, 0);
+    av_dict_set(&opt_dict, "headers", headers, AV_DICT_DONT_STRDUP_VAL);
     av_dict_set(&opt_dict, "chunked_post", "0", 0);
     av_dict_set(&opt_dict, "send_expect_100", s->legacy_icecast ? "-1" : "1", 0);
     if (NOT_EMPTY(s->content_type))
@@ -170,7 +170,6 @@  static int icecast_open(URLContext *h, const char *uri, int flags)
 
 cleanup:
     av_freep(&user);
-    av_freep(&headers);
     av_dict_free(&opt_dict);
 
     return ret;