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>
This commit is contained in:
parent
23a6e4749f
commit
abec6549ae
@ -193,6 +193,7 @@ typedef struct FFV1Context{
|
|||||||
int gob_count;
|
int gob_count;
|
||||||
int packed_at_lsb;
|
int packed_at_lsb;
|
||||||
int ec;
|
int ec;
|
||||||
|
int key_frame_ok;
|
||||||
|
|
||||||
int quant_table_count;
|
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
|
p->pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
|
||||||
if(get_rac(c, &keystate)){
|
if(get_rac(c, &keystate)){
|
||||||
p->key_frame= 1;
|
p->key_frame= 1;
|
||||||
|
f->key_frame_ok = 0;
|
||||||
if(read_header(f) < 0)
|
if(read_header(f) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if(init_slices_state(f) < 0)
|
if(init_slices_state(f) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
f->key_frame_ok = 1;
|
||||||
}else{
|
}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;
|
p->key_frame= 0;
|
||||||
}
|
}
|
||||||
if(f->ac>1){
|
if(f->ac>1){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user