aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-03-30 19:10:04 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-16 00:52:56 +0100
commit97978b7ae8e9313365e0702fe60e226b3c3e0dae (patch)
tree754ce400ef3cdd97c3b72bede03e494bd86119a0
parent3f2efac0fec16de92dd110723d73694e3e63946f (diff)
downloadffmpeg-97978b7ae8e9313365e0702fe60e226b3c3e0dae.tar.gz
h264: move the default_ref_list_done check down after its inputs have been written
Fixes out of array read Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 11c3381ce3c353a4dadf9def6232e7604b0c5d2b) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/h264.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 8bc8d7dbb0..4ecfa40466 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3110,7 +3110,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
unsigned int pps_id;
int num_ref_idx_active_override_flag, ret;
unsigned int slice_type, tmp, i, j;
- int default_ref_list_done = 0;
int last_pic_structure, last_pic_droppable;
int must_reinit;
int needs_reinit = 0;
@@ -3150,12 +3149,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
h->slice_type_fixed = 0;
slice_type = golomb_to_pict_type[slice_type];
- if (slice_type == AV_PICTURE_TYPE_I ||
- (h0->current_slice != 0 &&
- slice_type == h0->last_slice_type &&
- !memcmp(h0->last_ref_count, h0->ref_count, sizeof(h0->ref_count)))) {
- default_ref_list_done = 1;
- }
h->slice_type = slice_type;
h->slice_type_nos = slice_type & 3;
@@ -3595,9 +3588,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
h->list_count = 0;
h->ref_count[0] = h->ref_count[1] = 0;
}
-
- if (!default_ref_list_done)
+ if (slice_type != AV_PICTURE_TYPE_I &&
+ (h0->current_slice == 0 ||
+ slice_type != h0->last_slice_type ||
+ memcmp(h0->last_ref_count, h0->ref_count, sizeof(h0->ref_count)))) {
ff_h264_fill_default_ref_list(h);
+ }
if (h->slice_type_nos != AV_PICTURE_TYPE_I &&
ff_h264_decode_ref_pic_list_reordering(h) < 0) {