summaryrefslogtreecommitdiff
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-12-19 04:57:25 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-12-19 04:57:25 +0100
commit988d27b8029d9b4ccb13e792004cc8375b835eac (patch)
tree8931c74a18dcf3876f6db7569a7404b64ed5abab /libavformat/matroskaenc.c
parent76a8127a452f9e149a876c5fa6d6f0634e3b5b1e (diff)
parentb1306823d0b3ae998c8e10ad832004eb13bdd93e (diff)
Merge commit 'b1306823d0b3ae998c8e10ad832004eb13bdd93e'
* commit 'b1306823d0b3ae998c8e10ad832004eb13bdd93e': check memory errors from av_strdup() Conflicts: avprobe.c libavformat/matroskaenc.c libavutil/opt.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
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 c781c8aa0f..33c9ed182a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1084,13 +1084,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;
@@ -1112,6 +1115,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,
@@ -1135,11 +1139,15 @@ 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, "stereo_mode") &&
- 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;