[FFmpeg-devel] [PATCH 3/3] dict.c: empty dictionaries should be a NULL pointer.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Jul 29 21:26:50 CEST 2014


Ensure this is even the case if they are empty because
we failed adding the first entry.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavutil/dict.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavutil/dict.c b/libavutil/dict.c
index 2cd67e8..9063a57 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -122,6 +122,10 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
     return 0;
 
 err_out:
+    if (!m->count) {
+        av_free(m->elems);
+        av_freep(pm);
+    }
     if (flags & AV_DICT_DONT_STRDUP_KEY) av_free(key);
     if (flags & AV_DICT_DONT_STRDUP_VAL) av_free(value);
     return AVERROR(ENOMEM);
-- 
2.0.1



More information about the ffmpeg-devel mailing list