diff mbox

[FFmpeg-devel] avformat/mpegts: check end of init before treating SCTE data

Message ID CAF7m-44QQ6zQCNzV+ojZs=PB5xocnToDofkcAhAB=yKrz9Zjnw@mail.gmail.com
State New
Headers show

Commit Message

Anthony Delannoy Sept. 3, 2019, 4:09 p.m. UTC
Hi

On some DVB stream ffprobe segfaulted, it was because of SCTE-35 data
packet reception
before the end of MpegTSContext initialization.

On this patch I check for `ts->pkt` availability before trying to
generate a new SCTE data
packet.

Anthony Delannoy

Comments

Marton Balint Sept. 3, 2019, 7:55 p.m. UTC | #1
On Tue, 3 Sep 2019, Anthony Delannoy wrote:

> Hi
>
> On some DVB stream ffprobe segfaulted, it was because of SCTE-35 data
> packet reception
> before the end of MpegTSContext initialization.
>
> On this patch I check for `ts->pkt` availability before trying to
> generate a new SCTE data
> packet.
>

Thanks, applied.

Regards,
Marton
diff mbox

Patch

From 6dd92519ce5f7c85ca35c7227d35ff49fa6de3ef Mon Sep 17 00:00:00 2001
From: Anthony Delannoy <anthony.2lannoy@gmail.com>
Date: Tue, 3 Sep 2019 17:54:24 +0200
Subject: [PATCH] avformat/mpegts: Check if ready on SCTE reception

On some DVB stream SCTE-35 data packet are available before the end of
MpegTSContext initialization. We have to check if it is the case to
avoid a SEGFAULT.
---
 libavformat/mpegts.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 58902527c5..0415ceea02 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1725,6 +1725,13 @@  static void scte_data_cb(MpegTSFilter *filter, const uint8_t *section,
     if (idx < 0)
         return;
 
+    /**
+     * In case we receive an SCTE-35 packet before mpegts context is fully
+     * initialized.
+     */
+    if (!ts->pkt)
+        return;
+
     new_data_packet(section, section_len, ts->pkt);
     ts->pkt->stream_index = idx;
     prg = av_find_program_from_stream(ts->stream, NULL, idx);
-- 
2.23.0