ogg: Always alloc the private context in vorbis_header
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 13 Aug 2013 05:28:41 +0000 (07:28 +0200)
committerSean McGovern <gseanmcg@gmail.com>
Mon, 23 Sep 2013 23:41:09 +0000 (19:41 -0400)
It is possible to have an initial broken header and then valid packets.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
(cherry picked from commit 3562684db716d11de0b0dcc52748e9cd90d68132)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavformat/oggparsevorbis.c

index 7ec7a9e..272e50c 100644 (file)
@@ -208,15 +208,15 @@ vorbis_header (AVFormatContext * s, int idx)
     struct oggvorbis_private *priv;
     int pkt_type = os->buf[os->pstart];
 
-    if (!(pkt_type & 1))
-        return 0;
-
     if (!os->private) {
         os->private = av_mallocz(sizeof(struct oggvorbis_private));
         if (!os->private)
             return 0;
     }
 
+    if (!(pkt_type & 1))
+        return 0;
+
     if (os->psize < 1 || pkt_type > 5)
         return -1;