From 8ca1751f00455c4965e67c447aa3b0a4754dbc88 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 8 Jul 2013 08:44:43 +0200 Subject: [PATCH] mpegtsdemux: Avoid parsing section without enough data This is actually a workaround (we'll be skipping the upcoming section) This will only happen for sections where the beginning is located within the last 8 bytes of a packet (which is the minimum we need to properly identify any section beginning). Later we should figure out a way to store those bytes and mark that some analysis needs to happen. The probability of this happening is too low for me to care right now and do that fix. There is a good chance that section will eventually be repeated and won't end up on such border. --- gst/mpegtsdemux/mpegtspacketizer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c index 0c1841dd8e..2432469c28 100644 --- a/gst/mpegtsdemux/mpegtspacketizer.c +++ b/gst/mpegtsdemux/mpegtspacketizer.c @@ -972,7 +972,9 @@ accumulate_data: res = section; } - if (data == packet->data_end || *data == 0xff) { + /* FIXME : We need at least 8 bytes with current algorithm :( + * We might end up losing sections that start across two packets (srsl...) */ + if (data > packet->data_end - 8 || *data == 0xff) { /* flush stuffing bytes and leave */ mpegts_packetizer_clear_section (stream); goto out;