1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

avcodec/dnxhdenc: Fix segfault when using too many slice threads

The DNXHD encoder's context contains an array of 32 pointers to
DNXHDEncContexts used in case of slice threading; when trying
to use more than 32 threads with slice threading, the encoder's init
function errors out, but the close function takes avctx->thread_count
at face value and tries to free inexistent elements of the array,
leading to potential crashes.

Fix this by modifying the check used to decide whether the slice
contexts should be freed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit eb583b3cb9)
This commit is contained in:
Andreas Rheinhardt 2021-05-06 01:47:57 +02:00
parent 44f830e7f0
commit 2de8235791

View File

@ -1353,7 +1353,7 @@ static av_cold int dnxhd_encode_end(AVCodecContext *avctx)
av_freep(&ctx->qmatrix_c16);
av_freep(&ctx->qmatrix_l16);
if (avctx->active_thread_type == FF_THREAD_SLICE) {
if (ctx->thread[1]) {
for (i = 1; i < avctx->thread_count; i++)
av_freep(&ctx->thread[i]);
}