[FFmpeg-devel] [PATCH V1 07/12] lavc/libxavs2: fix memory leak after av_dict_parse_string fail

Jun Zhao mypopydev at gmail.com
Wed Jan 1 07:20:35 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/libxavs2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 2f8460a..91afeeb 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -100,8 +100,8 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
             while ((en = av_dict_get(dict, "", en, AV_DICT_IGNORE_SUFFIX))) {
                 xavs2_opt_set2(en->key, "%s", en->value);
             }
-            av_dict_free(&dict);
         }
+        av_dict_free(&dict);
     }
 
     /* Rate control */
-- 
1.7.1



More information about the ffmpeg-devel mailing list