mimic: Fix race condition
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 9 May 2013 23:18:12 +0000 (01:18 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 9 May 2013 23:40:24 +0000 (01:40 +0200)
Fixes access after free.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mimic.c

index 8985f6b..e2c9369 100644 (file)
@@ -175,7 +175,7 @@ static int mimic_decode_update_thread_context(AVCodecContext *avctx, const AVCod
 
     for (i = 0; i < FF_ARRAY_ELEMS(dst->frames); i++) {
         ff_thread_release_buffer(avctx, &dst->frames[i]);
-        if (src->frames[i].f->data[0]) {
+        if (i != src->next_cur_index && src->frames[i].f->data[0]) {
             ret = ff_thread_ref_frame(&dst->frames[i], &src->frames[i]);
             if (ret < 0)
                 return ret;