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

Submitted by Andreas Rheinhardt on Nov. 11, 2019, 1:12 a.m.

Details

Message ID 20191111011259.27313-3-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Nov. 11, 2019, 1:12 a.m.
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@gmail.com>
---
 libavformat/mpegts.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

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;