avformat/matroskadec: Use AV_DICT_DONT_STRDUP_VAL to save av_strdup
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 10 Nov 2019 04:07:31 +0000 (05:07 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 1 Jan 2020 15:38:28 +0000 (16:38 +0100)
This will likely also fix CID 1452562, 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).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/matroskadec.c

index 75f72d3..4d7fdab 100644 (file)
@@ -2403,8 +2403,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
 
         if (key_id_base64) {
             /* export encryption key id as base64 metadata tag */
-            av_dict_set(&st->metadata, "enc_key_id", key_id_base64, 0);
-            av_freep(&key_id_base64);
+            av_dict_set(&st->metadata, "enc_key_id", key_id_base64,
+                        AV_DICT_DONT_STRDUP_VAL);
         }
 
         if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC") &&
@@ -4111,8 +4111,8 @@ static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range)
         }
         end += ret;
     }
-    av_dict_set(&s->streams[0]->metadata, CUE_TIMESTAMPS, buf, 0);
-    av_free(buf);
+    av_dict_set(&s->streams[0]->metadata, CUE_TIMESTAMPS,
+                buf, AV_DICT_DONT_STRDUP_VAL);
 
     return 0;
 }
@@ -4137,8 +4137,8 @@ static int webm_dash_manifest_read_header(AVFormatContext *s)
     if (!matroska->is_live) {
         buf = av_asprintf("%g", matroska->duration);
         if (!buf) return AVERROR(ENOMEM);
-        av_dict_set(&s->streams[0]->metadata, DURATION, buf, 0);
-        av_free(buf);
+        av_dict_set(&s->streams[0]->metadata, DURATION,
+                    buf, AV_DICT_DONT_STRDUP_VAL);
 
         // initialization range
         // 5 is the offset of Cluster ID.