[FFmpeg-cvslog] vorbisdemux: Check private context in theoras gtopts.

Michael Niedermayer git at videolan.org
Fri Mar 23 04:45:21 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Mar 23 03:43:30 2012 +0100| [f927c5b753f2ec1f037ad38cb55b4407dd7a9d79] | committer: Michael Niedermayer

vorbisdemux: Check private context in theoras gtopts.

This prevents a null ptr dereference.
It could be checked differently but this way it should
be possible to return some data.

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f927c5b753f2ec1f037ad38cb55b4407dd7a9d79
---

 libavformat/oggparseskeleton.c |    5 ++++-
 libavformat/oggparsetheora.c   |    9 +++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/oggparseskeleton.c b/libavformat/oggparseskeleton.c
index 8d8e5dc..b0f55dd 100644
--- a/libavformat/oggparseskeleton.c
+++ b/libavformat/oggparseskeleton.c
@@ -74,8 +74,11 @@ static int skeleton_header(AVFormatContext *s, int idx)
         target_idx = ogg_find_stream(ogg, AV_RL32(buf+12));
         start_granule = AV_RL64(buf+36);
         if (target_idx >= 0 && start_granule != -1) {
+            int64_t pts = ogg_gptopts(s, target_idx, start_granule, NULL);
+            if (pts == AV_NOPTS_VALUE)
+                return -1;
             ogg->streams[target_idx].lastpts =
-            s->streams[target_idx]->start_time = ogg_gptopts(s, target_idx, start_granule, NULL);
+            s->streams[target_idx]->start_time = pts;
         }
     }
 
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index d1559f4..7ea4787 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -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++;



More information about the ffmpeg-cvslog mailing list