[FFmpeg-devel,16/23] avformat/matroskadec: Don't forward empty attachment filename

Submitted by Andreas Rheinhardt on Nov. 6, 2019, 2:49 a.m.

Details

Message ID 20191106024922.19228-16-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Nov. 6, 2019, 2:49 a.m.
While the Matroska specification allows the filename string to be empty,
forwarding an empty string as tag is useless.

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

Patch hide | download patch | download mbox

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index c224c3447a..0d15c634ee 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2881,7 +2881,10 @@  static int matroska_read_header(AVFormatContext *s)
             AVStream *st = avformat_new_stream(s, NULL);
             if (!st)
                 break;
-            av_dict_set(&st->metadata, "filename", attachments[j].filename, 0);
+
+            // Empty filenames are legal and accepted, but useless.
+            if (attachments[j].filename[0])
+                av_dict_set(&st->metadata, "filename", attachments[j].filename, 0);
             av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0);
             st->codecpar->codec_id   = AV_CODEC_ID_NONE;