[FFmpeg-devel] [PATCH 11/11] avformat/mpegts: Use AV_DICT_DONT_STRDUP_VAL to avoid av_strdup

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Mon Nov 11 03:12:59 EET 2019


This will likely also fix CID 1452589 and 1452460, 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 at gmail.com>
---
 libavformat/mpegts.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 587ed33327..e0f3a5eab9 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2611,6 +2611,7 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
                     desc_tag, desc_len);
 
             switch (desc_tag) {
+                AVProgram *program;
             case 0x48:
                 service_type = get8(&p, p_end);
                 if (service_type < 0)
@@ -2619,16 +2620,15 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
                 if (!provider_name)
                     break;
                 name = getstr8(&p, p_end);
-                if (name) {
-                    AVProgram *program = av_new_program(ts->stream, sid);
-                    if (program) {
-                        av_dict_set(&program->metadata, "service_name", name, 0);
-                        av_dict_set(&program->metadata, "service_provider",
-                                    provider_name, 0);
-                    }
+                if (name && (program = av_new_program(ts->stream, sid))) {
+                    av_dict_set(&program->metadata, "service_name",
+                                name, AV_DICT_DONT_STRDUP_VAL);
+                    av_dict_set(&program->metadata, "service_provider",
+                                provider_name, AV_DICT_DONT_STRDUP_VAL);
+                } else {
+                    av_free(name);
+                    av_free(provider_name);
                 }
-                av_free(name);
-                av_free(provider_name);
                 break;
             default:
                 break;
-- 
2.20.1



More information about the ffmpeg-devel mailing list