diff mbox series

[FFmpeg-devel,3/4] fftools/ffmpeg: Fix crash when flushing non-fully setup output stream

Message ID AM7PR03MB66601130A331882505C6F1C98FB29@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit fb215798c7a72b32e889b72efd018f26bb3f88ce
Headers show
Series [FFmpeg-devel,1/4] avfilter/avfiltergraph: Fix use-after-free when inserting auto-converter | expand


Context Check Description
andriy/configurex86 warning Failed to apply patch
andriy/configureppc warning Failed to apply patch

Commit Message

Andreas Rheinhardt Oct. 8, 2021, 8:14 a.m. UTC
The output stream's packet may not have been allocated
at that point. This happens when quitting in the following command line:
$ ./ffmpeg -lavfi abuffer=sample_fmt=u8:sample_rate=48000:channel_layout=stereo -f null -

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Is there actually a reason that this packet is not allocated together
with the input/output stream (instead checking every time in the
non-init codepath)?

 fftools/ffmpeg.c | 3 +++
 1 file changed, 3 insertions(+)


Paul B Mahol Oct. 8, 2021, 9:12 a.m. UTC | #1
diff mbox series


diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index bb29e3cec5..0e38d6d185 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1981,6 +1981,9 @@  static void flush_encoders(void)
             AVPacket *pkt = ost->pkt;
             int pkt_size;
+            if (!pkt)
+                break;
             switch (enc->codec_type) {
             case AVMEDIA_TYPE_AUDIO:
                 desc   = "audio";