Message ID | tencent_DB1E4D34A0764DD04F94D53AA70538871607@qq.com |
---|---|
State | Accepted |
Commit | 4f4dc0a1a29d3689ba8e73a08c13d4f2e152aad1 |
Headers | show |
Series | [FFmpeg-devel,v2,1/8] avfilter/dnn_filter_common: fix memleak | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of > Zhao Zhili > Sent: Saturday, September 2, 2023 4:24 PM > To: ffmpeg-devel@ffmpeg.org > Cc: Zhao Zhili <zhilizhao@tencent.com> > Subject: [FFmpeg-devel] [PATCH v2 8/8] avfilter/dnn_backend_openvino: fix > wild pointer on error path > > From: Zhao Zhili <zhilizhao@tencent.com> > > 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@tencent.com> > --- > libavfilter/dnn/dnn_backend_openvino.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > The patch set looks good to me, thanks.
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");