]> git.sesse.net Git - ffmpeg/commitdiff
lavfi/dnn_backend_openvino.c: fix mem leak for TaskItem upon error
authorGuo, Yejun <yejun.guo@intel.com>
Sat, 13 Mar 2021 06:14:51 +0000 (14:14 +0800)
committerGuo, Yejun <yejun.guo@intel.com>
Thu, 18 Mar 2021 01:30:09 +0000 (09:30 +0800)
libavfilter/dnn/dnn_backend_openvino.c

index 55cb0c757ed19597a21ef5bba6160389167dd536..9a47d74c1505f682f46b6c692fc7d21fd8b5458b 100644 (file)
@@ -678,12 +678,6 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *i
         return DNN_ERROR;
     }
 
-    task = av_malloc(sizeof(*task));
-    if (!task) {
-        av_log(ctx, AV_LOG_ERROR, "unable to alloc memory for task item.\n");
-        return DNN_ERROR;
-    }
-
     if (!ov_model->exe_network) {
         if (init_model_ov(ov_model, input_name, output_names[0]) != DNN_SUCCESS) {
             av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
@@ -691,6 +685,12 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *i
         }
     }
 
+    task = av_malloc(sizeof(*task));
+    if (!task) {
+        av_log(ctx, AV_LOG_ERROR, "unable to alloc memory for task item.\n");
+        return DNN_ERROR;
+    }
+
     task->done = 0;
     task->do_ioproc = 1;
     task->async = 1;