Fixes segfaults upon allocation failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
---
 fftools/ffmpeg.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 7beea11933..e9de8fb430 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -527,11 +527,13 @@ static void ffmpeg_cleanup(int ret)
         for (j = 0; j < fg->nb_inputs; j++) {
             InputFilter *ifilter = fg->inputs[j];
             struct InputStream *ist = ifilter->ist;
-            AVFrame *frame;
 
-            while (av_fifo_read(ifilter->frame_queue, &frame, 1) >= 0)
-                av_frame_free(&frame);
-            av_fifo_freep2(&ifilter->frame_queue);
+            if (ifilter->frame_queue) {
+                AVFrame *frame;
+                while (av_fifo_read(ifilter->frame_queue, &frame, 1) >= 0)
+                    av_frame_free(&frame);
+                av_fifo_freep2(&ifilter->frame_queue);
+            }
             av_freep(&ifilter->displaymatrix);
             if (ist->sub2video.sub_queue) {
                 AVSubtitle sub;
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to