[06/10] mpc8: Make sure the first stream exists before parsing the seek table

Message ID 1378932481-98398-6-git-send-email-martin@martin.st
State Committed
Commit 17d57848fc14e82f76a65ffb25c90f2f011dc4a0
Headers show

Commit Message

Martin Storsjö Sept. 11, 2013, 8:47 p.m.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
---
 libavformat/mpc8.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Luca Barbato Sept. 11, 2013, 9:04 p.m. | #1
On 11/09/13 22:47, Martin Storsjö wrote:
> Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> CC: libav-stable@libav.org
> ---
>  libavformat/mpc8.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 

Ok.

Patch

diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c
index 21b8403..606a0cd 100644
--- a/libavformat/mpc8.c
+++ b/libavformat/mpc8.c
@@ -139,6 +139,11 @@  static void mpc8_parse_seektable(AVFormatContext *s, int64_t off)
     int i, t, seekd;
     GetBitContext gb;
 
+    if (s->nb_streams == 0) {
+        av_log(s, AV_LOG_ERROR, "No stream added before parsing seek table\n");
+        return;
+    }
+
     avio_seek(s->pb, off, SEEK_SET);
     mpc8_get_chunk_header(s->pb, &tag, &size);
     if(tag != TAG_SEEKTABLE){