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

Submitted by Timo Rothenpieler on June 8, 2018, 4:31 p.m.

Details

Message ID 20180608163107.3112-1-timo@rothenpieler.org
State New
Headers show

Commit Message

Timo Rothenpieler June 8, 2018, 4:31 p.m.
Fixes CID #1435888
---
 libavfilter/dnn_backend_native.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

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){