If a key already exists in an AVDictionary and the AV_DICT_APPEND flag is set, the old entry is at first discarded from the dictionary, but a pointer to the value is kept. Lateron enough memory to store the appended string is allocated; should this allocation fail, the old string is not freed and hence leaks. This commit changes this.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- libavutil/dict.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index 0ea71386e5..190ef196be 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -115,8 +115,10 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, if (oldval && flags & AV_DICT_APPEND) { size_t len = strlen(oldval) + strlen(copy_value) + 1; char *newval = av_mallocz(len); - if (!newval) + if (!newval) { + av_free(oldval); goto err_out; + } av_strlcat(newval, oldval, len); av_freep(&oldval); av_strlcat(newval, copy_value, len); -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".