OSDN Git Service

oggparsetheora: make it more robust
authorLuca Barbato <lu_zero@gentoo.org>
Wed, 19 Sep 2012 23:33:47 +0000 (01:33 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 24 Sep 2012 20:35:29 +0000 (22:35 +0200)
libavformat/oggparsetheora.c

index 632c4ef..dfb73c9 100644 (file)
@@ -53,7 +53,8 @@ theora_header (AVFormatContext * s, int idx)
         os->private = thp;
     }
 
-    if (os->buf[os->pstart] == 0x80) {
+    switch (os->buf[os->pstart]) {
+    case 0x80: {
         GetBitContext gb;
         int width, height;
         AVRational timebase;
@@ -110,8 +111,16 @@ theora_header (AVFormatContext * s, int idx)
         st->codec->codec_id = AV_CODEC_ID_THEORA;
         st->need_parsing = AVSTREAM_PARSE_HEADERS;
 
-    } else if (os->buf[os->pstart] == 0x83) {
-        ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 7, os->psize - 8);
+    }
+    break;
+    case 0x81:
+        ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7, os->psize - 8);
+    case 0x82:
+        if (!thp->version)
+            return -1;
+        break;
+    default:
+        return -1;
     }
 
     st->codec->extradata = av_realloc (st->codec->extradata,