aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-11-07 23:37:59 +0100
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-11-17 23:15:07 +0100
commit9dee25fbc79661b8d11039eacb6b4cf8fe2fc1f9 (patch)
tree61fbcae33b3d9a329c1177534348d52d55142332
parentfa24e3780b7753a16c478dc3bff2f7b0319df5e5 (diff)
downloadffmpeg-9dee25fbc79661b8d11039eacb6b4cf8fe2fc1f9.tar.gz
mpegts: prevent division by zero
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> (cherry picked from commit 1bbb18fe82fc77a10d45fa53bd2738d2c54de6c6) Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-rw-r--r--libavformat/mpegts.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index fad10c6b06..0aa0ad77b8 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2681,8 +2681,17 @@ static int mpegts_read_header(AVFormatContext *s)
packet_count[nb_pcrs] = nb_packets;
pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;
nb_pcrs++;
- if (nb_pcrs >= 2)
- break;
+ if (nb_pcrs >= 2) {
+ if (pcrs[1] - pcrs[0] > 0) {
+ /* the difference needs to be positive to make sense for bitrate computation */
+ break;
+ } else {
+ av_log(ts->stream, AV_LOG_WARNING, "invalid pcr pair %"PRId64" >= %"PRId64"\n", pcrs[0], pcrs[1]);
+ pcrs[0] = pcrs[1];
+ packet_count[0] = packet_count[1];
+ nb_pcrs--;
+ }
+ }
} else {
finished_reading_packet(s, ts->raw_packet_size);
}