[FFmpeg-cvslog] avfilter/dnn_backend_openvino: fix wild pointer on error path
Zhao Zhili
git at videolan.org
Fri Sep 15 08:38:39 EEST 2023
ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Sat Sep 2 16:23:59 2023 +0800| [4f4dc0a1a29d3689ba8e73a08c13d4f2e152aad1] | committer: Guo Yejun
avfilter/dnn_backend_openvino: fix wild pointer on error path
When ov_model_const_input_by_name/ov_model_const_output_by_name
failed, input_port/output_port can be wild pointer.
Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4f4dc0a1a29d3689ba8e73a08c13d4f2e152aad1
---
libavfilter/dnn/dnn_backend_openvino.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 5de27719b2..ded156289b 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -210,7 +210,10 @@ static int fill_model_input_ov(OVModel *ov_model, OVRequestItem *request)
#if HAVE_OPENVINO2
if (!ov_model_is_dynamic(ov_model->ov_model)) {
- ov_output_const_port_free(ov_model->input_port);
+ if (ov_model->input_port) {
+ ov_output_const_port_free(ov_model->input_port);
+ ov_model->input_port = NULL;
+ }
status = ov_model_const_input_by_name(ov_model->ov_model, task->input_name, &ov_model->input_port);
if (status != OK) {
av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
@@ -621,8 +624,10 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char *
ov_model_free(tmp_ov_model);
//update output_port
- if (ov_model->output_port)
+ if (ov_model->output_port) {
ov_output_const_port_free(ov_model->output_port);
+ ov_model->output_port = NULL;
+ }
status = ov_model_const_output_by_name(ov_model->ov_model, output_name, &ov_model->output_port);
if (status != OK) {
av_log(ctx, AV_LOG_ERROR, "Failed to get output port.\n");
More information about the ffmpeg-cvslog
mailing list