summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-12-09 05:04:05 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-12-09 06:06:15 +0100
commite8ca7cfa4f4207be9b07e6135e6ba7a95ba89aa8 (patch)
treec5edd4737e0a5df59c2c9366998136838da732cb /libavcodec
parent4c554c967f748625abcf3ec96fce14792adf69cc (diff)
h264: avoid calling idr() twice
Fixes rare race condition leading to null pointer dereferences. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 2fbdc77e11..2616b0a38c 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3757,6 +3757,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
int pass = !(avctx->active_thread_type & FF_THREAD_FRAME);
int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
int nal_index;
+ int idr_cleared=0;
h->nal_unit_type= 0;
@@ -3900,7 +3901,9 @@ again:
buf_index = -1;
goto end;
}
- idr(h); // FIXME ensure we don't lose some frames if there is reordering
+ if(!idr_cleared)
+ idr(h); // FIXME ensure we don't lose some frames if there is reordering
+ idr_cleared = 1;
case NAL_SLICE:
init_get_bits(&hx->s.gb, ptr, bit_length);
hx->intra_gb_ptr =