summaryrefslogtreecommitdiff
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 8a7cfa128f..1d55b6629a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -936,13 +936,16 @@ static int mkv_write_chapters(AVFormatContext *s)
return 0;
}
-static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
+static int mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
{
uint8_t *key = av_strdup(t->key);
uint8_t *p = key;
const uint8_t *lang = NULL;
ebml_master tag;
+ if (!key)
+ return AVERROR(ENOMEM);
+
if ((p = strrchr(p, '-')) &&
(lang = av_convert_lang_to(p + 1, AV_LANG_ISO639_2_BIBL)))
*p = 0;
@@ -964,6 +967,7 @@ static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
end_ebml_master(pb, tag);
av_freep(&key);
+ return 0;
}
static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int elementid,
@@ -987,10 +991,14 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme
put_ebml_uint(s->pb, elementid, uid);
end_ebml_master(s->pb, targets);
- while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
+ while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) {
if (av_strcasecmp(t->key, "title") &&
- av_strcasecmp(t->key, "encoding_tool"))
- mkv_write_simpletag(s->pb, t);
+ av_strcasecmp(t->key, "encoding_tool")) {
+ ret = mkv_write_simpletag(s->pb, t);
+ if (ret < 0)
+ return ret;
+ }
+ }
end_ebml_master(s->pb, tag);
return 0;