From d80f255e10e7a5ef14df6479114a92dbd1c1c37f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Date: Sat, 15 Mar 2025 05:24:51 +0100 Subject: [PATCH 18/77] avcodec/pthread_slice: Return error on error Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/pthread_slice.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c index 4714fef106..f9da670735 100644 --- a/libavcodec/pthread_slice.c +++ b/libavcodec/pthread_slice.c @@ -132,14 +132,16 @@ av_cold int ff_slice_thread_init(AVCodecContext *avctx) } avctx->internal->thread_ctx = c = av_mallocz(sizeof(*c)); + if (!c) + return AVERROR(ENOMEM); mainfunc = ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SLICE_THREAD_HAS_MF ? &main_function : NULL; - if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, worker_func, mainfunc, thread_count)) <= 1) { - if (c) - avpriv_slicethread_free(&c->thread); - av_freep(&avctx->internal->thread_ctx); + thread_count = avpriv_slicethread_create(&c->thread, avctx, worker_func, + mainfunc, thread_count); + if (thread_count <= 1) { + ff_slice_thread_free(avctx); avctx->thread_count = 1; avctx->active_thread_type = 0; - return 0; + return thread_count < 0 ? thread_count : 0; } avctx->thread_count = thread_count; -- 2.45.2