[FFmpeg-cvslog] lavfi/dnn/dnn_backend_native: fix memory leak in error path

Jun Zhao git at videolan.org
Tue Aug 20 05:10:52 EEST 2019


ffmpeg | branch: master | Jun Zhao <barryjzhao at tencent.com> | Mon Aug 19 14:52:50 2019 +0800| [1b0a8e48f1d710800d2bd85795cfb3e93f28ab32] | committer: Jun Zhao

lavfi/dnn/dnn_backend_native: fix memory leak in error path

fix memory leak in error path

Reviewed-by: Guo, Yejun <yejun.guo at intel.com>
Signed-off-by: Jun Zhao <barryjzhao at tencent.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b0a8e48f1d710800d2bd85795cfb3e93f28ab32
---

 libavfilter/dnn/dnn_backend_native.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c
index 09c583b7eb..d52abc66e3 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -185,6 +185,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;
             }
@@ -192,6 +193,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;
             }



More information about the ffmpeg-cvslog mailing list