[FFmpeg-devel] [PATCH] avfilter/dnn_backend_native: fix leaks in error paths

Timo Rothenpieler timo at rothenpieler.org
Fri Jun 8 19:31:07 EEST 2018


Fixes CID #1435888
---
 libavfilter/dnn_backend_native.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/dnn_backend_native.c b/libavfilter/dnn_backend_native.c
index 6e80dd3663..e0a9ec5003 100644
--- a/libavfilter/dnn_backend_native.c
+++ b/libavfilter/dnn_backend_native.c
@@ -172,6 +172,7 @@ DNNModel* ff_dnn_load_model_native(const char* model_filename)
             conv_params->output_num <= 0 || conv_params->kernel_size <= 0){
             avio_closep(&model_file_context);
             ff_dnn_free_model_native(&model);
+            av_freep(&conv_params);
             return NULL;
         }
         conv_params->kernel = av_malloc(kernel_size * sizeof(float));
@@ -179,6 +180,9 @@ DNNModel* ff_dnn_load_model_native(const char* model_filename)
         if (!conv_params->kernel || !conv_params->biases){
             avio_closep(&model_file_context);
             ff_dnn_free_model_native(&model);
+            av_freep(&conv_params->kernel);
+            av_freep(&conv_params->biases);
+            av_freep(&conv_params);
             return NULL;
         }
         for (i = 0; i < kernel_size; ++i){
-- 
2.17.0



More information about the ffmpeg-devel mailing list