[FFmpeg-devel,5/7] avformat/matroskadec: Use AV_DICT_DONT_STRDUP_VAL to save av_strdup

Submitted by Andreas Rheinhardt on Nov. 10, 2019, 4:07 a.m.

Details

Message ID 20191110040733.11755-4-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Nov. 10, 2019, 4:07 a.m.
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>
---
 libavformat/matroskadec.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index c224c3447a..56863eb08e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2413,8 +2413,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") &&
@@ -4142,8 +4142,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;
 }
@@ -4168,8 +4168,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.