[FFmpeg-devel] [PATCH V1 4/5] lavfi/dnn/dnn_backend_native: fix memory leak in error path

Jun Zhao mypopydev at gmail.com
Mon Aug 19 16:01:06 EEST 2019


From: Jun Zhao <barryjzhao at tencent.com>

fix memory leak in error path

Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
---
 libavfilter/dnn/dnn_backend_native.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c
index 7b489d0..2619463 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -183,6 +183,7 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename)
             if (dnn_size > file_size || conv_params->input_num <= 0 ||
                 conv_params->output_num <= 0 || conv_params->kernel_size <= 0){
                 avio_closep(&model_file_context);
+                av_freep(&conv_params);
                 ff_dnn_free_model_native(&model);
                 return NULL;
             }
@@ -190,6 +191,9 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename)
             conv_params->biases = av_malloc(conv_params->output_num * sizeof(float));
             if (!conv_params->kernel || !conv_params->biases){
                 avio_closep(&model_file_context);
+                av_freep(&conv_params->kernel);
+                av_freep(&conv_params->biases);
+                av_freep(&conv_params);
                 ff_dnn_free_model_native(&model);
                 return NULL;
             }
-- 
1.7.1



More information about the ffmpeg-devel mailing list