diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2014-12-17 14:53:45 +0100 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2014-12-18 23:27:14 +0100 |
commit | b1306823d0b3ae998c8e10ad832004eb13bdd93e (patch) | |
tree | 2e7642dc896d7f19682f50b913ab5b5be57b83ac /libavformat/matroskaenc.c | |
parent | 9745f19ffc9031ce480e43d7cf1053b58100d70f (diff) | |
download | ffmpeg-b1306823d0b3ae998c8e10ad832004eb13bdd93e.tar.gz |
check memory errors from av_strdup()
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r-- | libavformat/matroskaenc.c | 16 |
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; |