diff mbox

[FFmpeg-devel,10/11] avformat/oggparsevorbis: Use AV_DICT_DONT_STRDUP_VAL to avoid av_strdup

Message ID 20191111011259.27313-2-andreas.rheinhardt@gmail.com
State Accepted
Headers show

Commit Message

Andreas Rheinhardt Nov. 11, 2019, 1:12 a.m. UTC
This will likely also fix CID 1452427, a false positive resulting from
Coverity thinking that av_dict_set() automatically frees its key and
value parameters (even without the AV_DICT_DONT_STRDUP_* flags).

(AV_DICT_APPEND and AV_DICT_DONT_STRDUP_VAL are compatible with each
other since a8c5b455, so we can reset this flag here. It has originally
been removed in 0dc66553 when appending was added.)

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

Comments

Andreas Rheinhardt Jan. 16, 2020, 7:27 p.m. UTC | #1
On Mon, Nov 11, 2019 at 2:13 AM Andreas Rheinhardt <
andreas.rheinhardt@gmail.com> wrote:

> This will likely also fix CID 1452427, a false positive resulting from
> Coverity thinking that av_dict_set() automatically frees its key and
> value parameters (even without the AV_DICT_DONT_STRDUP_* flags).
>
> (AV_DICT_APPEND and AV_DICT_DONT_STRDUP_VAL are compatible with each
> other since a8c5b455, so we can reset this flag here. It has originally
> been removed in 0dc66553 when appending was added.)
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/oggparsevorbis.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
> index 43f05f928a..8dd27e7770 100644
> --- a/libavformat/oggparsevorbis.c
> +++ b/libavformat/oggparsevorbis.c
> @@ -177,9 +177,8 @@ int ff_vorbis_comment(AVFormatContext *as,
> AVDictionary **m,
>                      av_dict_set(m, tt, ";", AV_DICT_APPEND);
>                  }
>                  av_dict_set(m, tt, ct,
> -                            AV_DICT_DONT_STRDUP_KEY |
> +                            AV_DICT_DONT_STRDUP_KEY |
> AV_DICT_DONT_STRDUP_VAL |
>                              AV_DICT_APPEND);
> -                av_freep(&ct);
>              }
>          }
>      }
> --
> 2.20.1
>
>
Ping.

- Andreas
Michael Niedermayer Jan. 17, 2020, 8:15 p.m. UTC | #2
On Mon, Nov 11, 2019 at 02:12:58AM +0100, Andreas Rheinhardt wrote:
> This will likely also fix CID 1452427, a false positive resulting from
> Coverity thinking that av_dict_set() automatically frees its key and
> value parameters (even without the AV_DICT_DONT_STRDUP_* flags).
> 
> (AV_DICT_APPEND and AV_DICT_DONT_STRDUP_VAL are compatible with each
> other since a8c5b455, so we can reset this flag here. It has originally
> been removed in 0dc66553 when appending was added.)
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/oggparsevorbis.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 43f05f928a..8dd27e7770 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -177,9 +177,8 @@  int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
                     av_dict_set(m, tt, ";", AV_DICT_APPEND);
                 }
                 av_dict_set(m, tt, ct,
-                            AV_DICT_DONT_STRDUP_KEY |
+                            AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL |
                             AV_DICT_APPEND);
-                av_freep(&ct);
             }
         }
     }