From 541f9ba34db9e9d4effc17c54ee7891c1a0bba5d Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 27 Jul 2024 02:18:45 +0530 Subject: [PATCH] svtav1enc: Fix segfault when flushing gst_video_encoder_get_oldest_frame() is nullable, and will signal that all frames are handled by returning NULL. Fixes #3650 Part-of: --- subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c b/subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c index 935a25fe4c..5e19a0b363 100644 --- a/subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c +++ b/subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c @@ -888,8 +888,13 @@ gst_svtav1enc_dequeue_encoded_frames (GstSvtAv1Enc * svtav1enc, return GST_FLOW_ERROR; } else if (res != EB_NoErrorEmptyQueue && output_frames && output_buf) { // AV1 has no frame re-ordering so always get the oldest frame - frame = - gst_video_encoder_get_oldest_frame (GST_VIDEO_ENCODER (svtav1enc)); + if (!(frame = + gst_video_encoder_get_oldest_frame (GST_VIDEO_ENCODER + (svtav1enc)))) { + svt_av1_enc_release_out_buffer (&output_buf); + break; + } + if (output_buf->pic_type == EB_AV1_KEY_PICTURE || output_buf->pic_type == EB_AV1_INTRA_ONLY_PICTURE) { GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);