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

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

diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index a5aedd5..13ebe53 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -254,8 +254,8 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx)
                 if (parse_ret < 0)
                     av_log(avctx, AV_LOG_WARNING, "Invalid value for %s: %s.\n", en->key, en->value);
             }
-            av_dict_free(&dict);
         }
+        av_dict_free(&dict);
     }
 
     rret = rav1e_config_parse_int(cfg, "width", avctx->width);
-- 
1.7.1



More information about the ffmpeg-devel mailing list