aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2014-06-08 17:53:31 +0200
committerJanne Grunau <janne-libav@jannau.net>2014-06-09 12:33:19 +0200
commit1619274fb393f55a365cc10f88faa173c9a8e772 (patch)
tree2084622f5a6f8e61c65f79a19b30e47477c9046a
parent7b06ddb8352fe7f434414d7911ced94956bb25b2 (diff)
downloadffmpeg-1619274fb393f55a365cc10f88faa173c9a8e772.tar.gz
av_dict_set: fix potential memory leak with AV_DICT_DONT_OVERWRITE
av_dict_set leaks it key/value arguments if AV_DICT_DONT_OVERWRITE is combined with AV_DICT_DONT_STRDUP_{KEY,VAL} and the key exists.
-rw-r--r--libavutil/dict.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavutil/dict.c b/libavutil/dict.c
index 7b4dbf29ac..e4ea7769e0 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -76,8 +76,11 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
m = *pm = av_mallocz(sizeof(*m));
if (tag) {
- if (flags & AV_DICT_DONT_OVERWRITE)
+ if (flags & AV_DICT_DONT_OVERWRITE) {
+ if (flags & AV_DICT_DONT_STRDUP_KEY) av_free(key);
+ if (flags & AV_DICT_DONT_STRDUP_VAL) av_free(value);
return 0;
+ }
if (flags & AV_DICT_APPEND)
oldval = tag->value;
else