summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-04-22 13:56:07 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-04-22 14:58:28 +0200
commitabec6549ae1e86fdf89dbab8a8abca8eb7205c6e (patch)
tree070a49406660c9de90e7532754816db13802cc01 /libavcodec
parent23a6e4749fa7134ce411ce186062f70f9d348603 (diff)
ffv1dec: Require a valid keyframe for decoding non keyframes.
Before this the context could become inconsistent, this lead to a null ptr dereference. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ffv1.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 491b3f5d32..ac37216c7d 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -193,6 +193,7 @@ typedef struct FFV1Context{
int gob_count;
int packed_at_lsb;
int ec;
+ int key_frame_ok;
int quant_table_count;
@@ -1945,11 +1946,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
p->pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
if(get_rac(c, &keystate)){
p->key_frame= 1;
+ f->key_frame_ok = 0;
if(read_header(f) < 0)
return -1;
if(init_slices_state(f) < 0)
return -1;
+ f->key_frame_ok = 1;
}else{
+ if (!f->key_frame_ok) {
+ av_log(avctx, AV_LOG_ERROR, "Cant decode non keyframe without valid keyframe\n");
+ return AVERROR_INVALIDDATA;
+ }
p->key_frame= 0;
}
if(f->ac>1){