From a6e4796fbf0aa9b13451a8ef917ecc4e80d1d272 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 13 Jan 2013 05:42:01 +0100 Subject: [PATCH] pthread: Do not use a half updated context as master for deallocation. Fixes assertion failure Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/pthread.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index b55cccf200..2bd8df8e0a 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -754,7 +754,11 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count) park_frame_worker_threads(fctx, thread_count); if (fctx->prev_thread && fctx->prev_thread != fctx->threads) - update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0); + if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) { + av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n"); + fctx->prev_thread->avctx->internal->is_copy = fctx->threads->avctx->internal->is_copy; + fctx->threads->avctx->internal->is_copy = 1; + } fctx->die = 1;