History

dnn_backend_openvino.c: refine code for error handle

Guo, Yejun committed 5 years ago

Commit 38089921 parent 2b177031 file · +6 −16Browse files

Unified · Split

libavfilter/dnn/dnn_backend_openvino.c+6−16
@@ -336,8 +336,11 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, · 335 unmodified lines
336336 }
337337
338338 ov_model = av_mallocz(sizeof(OVModel));
339− if (!ov_model)
340− goto err;
339+ if (!ov_model) {
340+ av_freep(&model);
341+ return NULL;
342+ }
343+ model->model = (void *)ov_model;
341344 ov_model->model = model;
342345 ov_model->ctx.class = &dnn_openvino_class;
343346 ctx = &ov_model->ctx;
@@ -377,7 +380,6 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, · 33 unmodified lines
377380 if (status != OK)
378381 goto err;
379382
380− model->model = (void *)ov_model;
381383 model->get_input = &get_input_ov;
382384 model->get_output = &get_output_ov;
383385 model->options = options;
@@ -386,19 +388,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options, · 2 unmodified lines
386388 return model;
387389
388390 err:
389− if (model)
390− av_freep(&model);
391− if (ov_model) {
392− if (ov_model->infer_request)
393− ie_infer_request_free(&ov_model->infer_request);
394− if (ov_model->exe_network)
395− ie_exec_network_free(&ov_model->exe_network);
396− if (ov_model->network)
397− ie_network_free(&ov_model->network);
398− if (ov_model->core)
399− ie_core_free(&ov_model->core);
400− av_freep(&ov_model);
401− }
391+ ff_dnn_free_model_ov(&model);
402392 return NULL;
403393 }
404394

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t