summaryrefslogtreecommitdiff
path: root/libavutil/dict.c
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2014-12-12 18:15:39 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-12-12 23:40:50 +0100
commita963fdb0ea3fa6772ff8464838cd217a6369abfe (patch)
tree89d61920e9d745ebc6e8ed4ff44c37f477a98a5c /libavutil/dict.c
parenta66893ac949864352b36b39e48c4cd72bbd81e54 (diff)
lavu/dict: check for malloc failures
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/dict.c')
-rw-r--r--libavutil/dict.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavutil/dict.c b/libavutil/dict.c
index 2983ea57a9..a362de07d7 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -75,6 +75,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
if (!m)
m = *pm = av_mallocz(sizeof(*m));
+ if (!m)
+ goto err_out;
if (tag) {
if (flags & AV_DICT_DONT_OVERWRITE) {
@@ -100,6 +102,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
m->elems[m->count].key = (char*)(intptr_t)key;
else
m->elems[m->count].key = av_strdup(key);
+ if (!m->elems[m->count].key)
+ goto err_out;
if (flags & AV_DICT_DONT_STRDUP_VAL) {
m->elems[m->count].value = (char*)(intptr_t)value;
} else if (oldval && flags & AV_DICT_APPEND) {
@@ -123,7 +127,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
return 0;
err_out:
- if (!m->count) {
+ if (m && !m->count) {
av_free(m->elems);
av_freep(pm);
}