From aa6b44db4e1983a4c3a88839518251cfb870a648 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Thu, 18 Jul 2024 09:27:00 +0200 Subject: [PATCH] opencv: check the image conversion worked Otherwise we release the output picture that would have been used and returned. (cherry picked from commit 19813291fcfb31ddd91a2e4d0f1d37ad3239d300) (rebased) rebased: - p_filter->p_sys is p_sys on 4.0 Signed-off-by: Steve Lhomme Gbp-Pq: Name 0019-opencv-check-the-image-conversion-worked.patch --- modules/video_filter/opencv_wrapper.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/video_filter/opencv_wrapper.c b/modules/video_filter/opencv_wrapper.c index 5da26a17..2d5966ba 100644 --- a/modules/video_filter/opencv_wrapper.c +++ b/modules/video_filter/opencv_wrapper.c @@ -444,9 +444,16 @@ static picture_t* Filter( filter_t* p_filter, picture_t* p_pic ) p_filter->p_sys->p_proc_image, &(p_filter->p_sys->p_proc_image->format), &fmt_out ); - - picture_CopyPixels( p_outpic, p_outpic_tmp ); - CopyInfoAndRelease( p_outpic, p_outpic_tmp ); + if (unlikely(!p_outpic_tmp)) + { + picture_Release(p_outpic); + p_outpic = NULL; + } + else + { + picture_CopyPixels( p_outpic, p_outpic_tmp ); + CopyInfoAndRelease( p_outpic, p_outpic_tmp ); + } } else if( p_filter->p_sys->i_internal_chroma == CINPUT ) { picture_CopyPixels( p_outpic, p_filter->p_sys->p_proc_image ); picture_CopyProperties( p_outpic, p_filter->p_sys->p_proc_image ); -- 2.30.2