1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-04-24 17:12:34 +02:00

avutil/dict: Use av_freep() to avoid leaving stale pointers in memory

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-12-27 15:48:32 +01:00
parent 9e89347329
commit 336bb3f706

View File

@ -120,7 +120,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
m->count++; m->count++;
} }
if (!m->count) { if (!m->count) {
av_free(m->elems); av_freep(&m->elems);
av_freep(pm); av_freep(pm);
} }
@ -128,7 +128,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
err_out: err_out:
if (m && !m->count) { if (m && !m->count) {
av_free(m->elems); av_freep(&m->elems);
av_freep(pm); av_freep(pm);
} }
if (flags & AV_DICT_DONT_STRDUP_KEY) av_free((void*)key); if (flags & AV_DICT_DONT_STRDUP_KEY) av_free((void*)key);
@ -197,10 +197,10 @@ void av_dict_free(AVDictionary **pm)
if (m) { if (m) {
while (m->count--) { while (m->count--) {
av_free(m->elems[m->count].key); av_freep(&m->elems[m->count].key);
av_free(m->elems[m->count].value); av_freep(&m->elems[m->count].value);
} }
av_free(m->elems); av_freep(&m->elems);
} }
av_freep(pm); av_freep(pm);
} }