diff options
Diffstat (limited to 'ffmpeg/libavformat/bfi.c')
| -rw-r--r-- | ffmpeg/libavformat/bfi.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ffmpeg/libavformat/bfi.c b/ffmpeg/libavformat/bfi.c index a28e09a..b65a582 100644 --- a/ffmpeg/libavformat/bfi.c +++ b/ffmpeg/libavformat/bfi.c @@ -81,6 +81,8 @@ static int bfi_read_header(AVFormatContext * s) /*Load the palette to extradata */ avio_skip(pb, 8); vstream->codec->extradata = av_malloc(768); + if (!vstream->codec->extradata) + return AVERROR(ENOMEM); vstream->codec->extradata_size = 768; avio_read(pb, vstream->codec->extradata, vstream->codec->extradata_size); @@ -134,6 +136,10 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt) video_offset = avio_rl32(pb); audio_size = video_offset - audio_offset; bfi->video_size = chunk_size - video_offset; + if (audio_size < 0 || bfi->video_size < 0) { + av_log(s, AV_LOG_ERROR, "Invalid audio/video offsets or chunk size\n"); + return AVERROR_INVALIDDATA; + } //Tossing an audio packet at the audio decoder. ret = av_get_packet(pb, pkt, audio_size); @@ -142,9 +148,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt) pkt->pts = bfi->audio_frame; bfi->audio_frame += ret; - } - - else { + } else if (bfi->video_size > 0) { //Tossing a video packet at the video decoder. ret = av_get_packet(pb, pkt, bfi->video_size); @@ -152,10 +156,13 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt) return ret; pkt->pts = bfi->video_frame; - bfi->video_frame += bfi->video_size ? ret / bfi->video_size : 1; + bfi->video_frame += ret / bfi->video_size; /* One less frame to read. A cursory decrement. */ bfi->nframes--; + } else { + /* Empty video packet */ + ret = AVERROR(EAGAIN); } bfi->avflag = !bfi->avflag; |
