[FFmpeg-devel] [PATCH V2 1/5] lavc/bsf: fix memory leak after av_dict_parse_string fail

Jun Zhao mypopydev at gmail.com
Thu Jan 2 13:55:01 EET 2020


From: Jun Zhao <barryjzhao at tencent.com>

In case of failure, all the successfully set entries are stored in
*pm. We need to manually free the created dictionary to avoid
memory leak.

Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
---
 libavcodec/bsf.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index c1653cd..8e1af60 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -517,8 +517,8 @@ static int bsf_parse_single(const char *str, AVBSFList *bsf_lst)
 
     ret = av_bsf_list_append2(bsf_lst, bsf_name, &bsf_options);
 
-    av_dict_free(&bsf_options);
 end:
+    av_dict_free(&bsf_options);
     av_free(buf);
     return ret;
 }
-- 
1.7.1



More information about the ffmpeg-devel mailing list