From 27da681919271e9301e0962bf952adf9407bd845 Mon Sep 17 00:00:00 2001 From: lijiahao Date: Wed, 2 Jul 2025 11:50:50 +0800 Subject: [PATCH] Validate thread count in thpool_init() and return NULL for non-positive values --- thpool.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/thpool.c b/thpool.c index 83885c3..41c4fda 100644 --- a/thpool.c +++ b/thpool.c @@ -142,9 +142,10 @@ struct thpool_* thpool_init(int num_threads){ threads_on_hold = 0; threads_keepalive = 1; - if (num_threads < 0){ - num_threads = 0; - } + if (num_threads <= 0){ + err("thpool_init(): thread count must be > 0\n"); + return NULL; + } /* Make new thread pool */ thpool_* thpool_p;