diff mbox series

[FFmpeg-devel,V1,10/12] lavf/hlsenc: fix memory leak after av_dict_parse_string fail

Message ID 1577856040-17409-10-git-send-email-mypopydev@gmail.com
State New
Headers show
Series [FFmpeg-devel,V1,01/12] lavc/bsf: fix memory leak after av_dict_parse_string fail
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork fail Failed to apply patch

Commit Message

Jun Zhao Jan. 1, 2020, 5:20 a.m. UTC
From: Jun Zhao <barryjzhao@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@tencent.com>
---
 libavformat/hlsenc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 6551e1c..df19545 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -856,6 +856,7 @@  static int hls_mux_init(AVFormatContext *s, VariantStream *vs)
     if (hls->format_options_str) {
         ret = av_dict_parse_string(&hls->format_options, hls->format_options_str, "=", ":", 0);
         if (ret < 0) {
+            av_dict_free(&hls->format_options);
             av_log(s, AV_LOG_ERROR, "Could not parse format options list '%s'\n",
                    hls->format_options_str);
             return ret;
@@ -2781,6 +2782,7 @@  static int hls_init(AVFormatContext *s)
         if (hls->format_options_str) {
             ret = av_dict_parse_string(&hls->format_options, hls->format_options_str, "=", ":", 0);
             if (ret < 0) {
+                av_dict_free(&hls->format_options);
                 av_log(s, AV_LOG_ERROR, "Could not parse format options list '%s'\n", hls->format_options_str);
                 goto fail;
             }