You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
lavu/dict: check for malloc failures
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -75,6 +75,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
|
|||||||
|
|
||||||
if (!m)
|
if (!m)
|
||||||
m = *pm = av_mallocz(sizeof(*m));
|
m = *pm = av_mallocz(sizeof(*m));
|
||||||
|
if (!m)
|
||||||
|
goto err_out;
|
||||||
|
|
||||||
if (tag) {
|
if (tag) {
|
||||||
if (flags & AV_DICT_DONT_OVERWRITE) {
|
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;
|
m->elems[m->count].key = (char*)(intptr_t)key;
|
||||||
else
|
else
|
||||||
m->elems[m->count].key = av_strdup(key);
|
m->elems[m->count].key = av_strdup(key);
|
||||||
|
if (!m->elems[m->count].key)
|
||||||
|
goto err_out;
|
||||||
if (flags & AV_DICT_DONT_STRDUP_VAL) {
|
if (flags & AV_DICT_DONT_STRDUP_VAL) {
|
||||||
m->elems[m->count].value = (char*)(intptr_t)value;
|
m->elems[m->count].value = (char*)(intptr_t)value;
|
||||||
} else if (oldval && flags & AV_DICT_APPEND) {
|
} 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;
|
return 0;
|
||||||
|
|
||||||
err_out:
|
err_out:
|
||||||
if (!m->count) {
|
if (m && !m->count) {
|
||||||
av_free(m->elems);
|
av_free(m->elems);
|
||||||
av_freep(pm);
|
av_freep(pm);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user