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

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

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 963c28f..3836049 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -262,8 +262,8 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
                     break;
                 }
             }
-            av_dict_free(&dict);
         }
+        av_dict_free(&dict);
     }
 
     if (ctx->params->rc.vbvBufferSize && avctx->rc_initial_buffer_occupancy > 1000 &&
-- 
1.7.1



More information about the ffmpeg-devel mailing list