]> git.sesse.net Git - ffmpeg/commitdiff
avformat/brstm: clip timestamp when seeking into acceptable range
authorPaul B Mahol <onemda@gmail.com>
Thu, 10 Sep 2020 15:23:41 +0000 (17:23 +0200)
committerPaul B Mahol <onemda@gmail.com>
Thu, 10 Sep 2020 15:38:08 +0000 (17:38 +0200)
libavformat/brstm.c

index ca965ed7e1999f8e76d73a75e0e45bfddeea7aed..a63c7ee5abe4c67ce96f5a2ce8fc31d6da18294b 100644 (file)
@@ -446,7 +446,11 @@ static int read_seek(AVFormatContext *s, int stream_index,
     BRSTMDemuxContext *b = s->priv_data;
     int64_t ret = 0;
 
+    if (timestamp < 0)
+        timestamp = 0;
     timestamp /= b->samples_per_block;
+    if (timestamp >= b->block_count)
+        timestamp = b->block_count - 1;
     ret = avio_seek(s->pb, b->data_start + timestamp * b->block_size *
                            st->codecpar->channels, SEEK_SET);
     if (ret < 0)