ogg: prevent NULL pointer deference in theora gptopts
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 23 Mar 2012 02:43:30 +0000 (03:43 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 24 Sep 2012 20:35:29 +0000 (22:35 +0200)
Additional safety in case a special ogg stream is crafted
with the proper number of

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/oggparsetheora.c

index df7a89c..632c4ef 100644 (file)
@@ -131,8 +131,13 @@ theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp, int64_t *dts)
     struct ogg *ogg = ctx->priv_data;
     struct ogg_stream *os = ogg->streams + idx;
     struct theora_params *thp = os->private;
-    uint64_t iframe = gp >> thp->gpshift;
-    uint64_t pframe = gp & thp->gpmask;
+    uint64_t iframe, pframe;
+
+    if (!thp)
+        return AV_NOPTS_VALUE;
+
+    iframe = gp >> thp->gpshift;
+    pframe = gp & thp->gpmask;
 
     if (thp->version < 0x030201)
         iframe++;