diff mbox

[FFmpeg-devel,7/7] avformat/mov: Use AV_DICT_DONT_STRDUP_VAL to avoid av_strdup

Message ID 20191110040733.11755-6-andreas.rheinhardt@gmail.com
State Accepted
Headers show

Commit Message

Andreas Rheinhardt Nov. 10, 2019, 4:07 a.m. UTC
This will likely also fix CID 1452574 and 1452565, false positives
resulting from Coverity thinking that av_dict_set() automatically
frees its key and value parameters (even without the
AV_DICT_DONT_STRDUP_* flags).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/mov.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Andreas Rheinhardt Jan. 9, 2020, 6:27 p.m. UTC | #1
On Sun, Nov 10, 2019 at 5:07 AM Andreas Rheinhardt <
andreas.rheinhardt@gmail.com> wrote:

> This will likely also fix CID 1452574 and 1452565, false positives
> resulting from Coverity thinking that av_dict_set() automatically
> frees its key and value parameters (even without the
> AV_DICT_DONT_STRDUP_* flags).
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/mov.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index d5c67fbc68..df010c68ac 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1129,8 +1129,8 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext
> *pb, MOVAtom atom)
>          return ret;
>      }
>      comp_brands_str[comp_brand_size] = 0;
> -    av_dict_set(&c->fc->metadata, "compatible_brands", comp_brands_str,
> 0);
> -    av_freep(&comp_brands_str);
> +    av_dict_set(&c->fc->metadata, "compatible_brands",
> +                comp_brands_str, AV_DICT_DONT_STRDUP_VAL);
>
>      return 0;
>  }
> @@ -5801,8 +5801,8 @@ static int mov_read_uuid(MOVContext *c, AVIOContext
> *pb, MOVAtom atom)
>                  return AVERROR_INVALIDDATA;
>              }
>              buffer[len] = '\0';
> -            av_dict_set(&c->fc->metadata, "xmp", buffer, 0);
> -            av_free(buffer);
> +            av_dict_set(&c->fc->metadata, "xmp",
> +                        buffer, AV_DICT_DONT_STRDUP_VAL);
>          } else {
>              // skip all uuid atom, which makes it fast for long uuid-xmp
> file
>              ret = avio_skip(pb, len);
> --
> 2.20.1
>
>
Ping.

- Andreas
Michael Niedermayer Jan. 10, 2020, 4:31 p.m. UTC | #2
On Sun, Nov 10, 2019 at 05:07:33AM +0100, Andreas Rheinhardt wrote:
> This will likely also fix CID 1452574 and 1452565, false positives
> resulting from Coverity thinking that av_dict_set() automatically
> frees its key and value parameters (even without the
> AV_DICT_DONT_STRDUP_* flags).
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/mov.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d5c67fbc68..df010c68ac 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1129,8 +1129,8 @@  static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         return ret;
     }
     comp_brands_str[comp_brand_size] = 0;
-    av_dict_set(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
-    av_freep(&comp_brands_str);
+    av_dict_set(&c->fc->metadata, "compatible_brands",
+                comp_brands_str, AV_DICT_DONT_STRDUP_VAL);
 
     return 0;
 }
@@ -5801,8 +5801,8 @@  static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
                 return AVERROR_INVALIDDATA;
             }
             buffer[len] = '\0';
-            av_dict_set(&c->fc->metadata, "xmp", buffer, 0);
-            av_free(buffer);
+            av_dict_set(&c->fc->metadata, "xmp",
+                        buffer, AV_DICT_DONT_STRDUP_VAL);
         } else {
             // skip all uuid atom, which makes it fast for long uuid-xmp file
             ret = avio_skip(pb, len);