lavfi/dnn/dnn_backend_native: fix memory leak in error path
authorJun Zhao <barryjzhao@tencent.com>
Mon, 19 Aug 2019 06:52:50 +0000 (14:52 +0800)
committerJun Zhao <barryjzhao@tencent.com>
Tue, 20 Aug 2019 02:07:38 +0000 (10:07 +0800)
fix memory leak in error path

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
libavfilter/dnn/dnn_backend_native.c

index 09c583b..d52abc6 100644 (file)
@@ -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;
             }