summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2008-12-16 08:47:28 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2008-12-16 08:47:28 +0000
commit271344377a3391c1a8ccc45e021721a56f237612 (patch)
tree29b6e1180dd5df86bbf0b562e3580f8b957d8bc2 /libavformat
parentf683ea1cab7a8e8dd040ea2fec53abf57a4bbf45 (diff)
check that nb_streams is valid before setting stream, fix crash with jp2 which do not use same structure
Originally committed as revision 16166 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mov.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index ff7be4b60d..dd44bab15d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -599,9 +599,14 @@ static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
/* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */
static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
- AVStream *st = c->fc->streams[c->fc->nb_streams-1];
- uint64_t size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE;
+ AVStream *st;
+ uint64_t size;
uint8_t *buf;
+
+ if (c->fc->nb_streams < 1) // will happen with jp2 files
+ return 0;
+ st= c->fc->streams[c->fc->nb_streams-1];
+ size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE;
if(size > INT_MAX || (uint64_t)atom.size > INT_MAX)
return -1;
buf= av_realloc(st->codec->extradata, size);