From 66904f814853d1d34aed020eebbd826e8466f029 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 19 Jul 2023 22:14:34 +0200 Subject: [PATCH 1/2] Ensure that a premature call will not overwrite unrelated memory --- driver/others/blas_server_win32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/others/blas_server_win32.c b/driver/others/blas_server_win32.c index afa33cccc..5bdfc1276 100644 --- a/driver/others/blas_server_win32.c +++ b/driver/others/blas_server_win32.c @@ -568,7 +568,7 @@ void goto_set_num_threads(int num_threads) blas_server_avail = 1; } - for(i = blas_num_threads - 1; i < num_threads - 1; i++){ + for(i = (blas_num_threads > 0) ? blas_num_threads - 1 : 0; i < num_threads - 1; i++){ blas_threads[i] = CreateThread(NULL, 0, blas_thread_server, (void *)i, From b34f19a365a43ce8a05c29a97036bfc9e300c289 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 19 Jul 2023 22:19:22 +0200 Subject: [PATCH 2/2] Ensure that a premature call to set_num_threads will not overwrite unrelated memory --- driver/others/blas_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/others/blas_server.c b/driver/others/blas_server.c index 051513f27..a8a84acbb 100644 --- a/driver/others/blas_server.c +++ b/driver/others/blas_server.c @@ -973,7 +973,7 @@ void goto_set_num_threads(int num_threads) { increased_threads = 1; - for(i = blas_num_threads - 1; i < num_threads - 1; i++){ + for(i = (blas_num_threads > 0) ? blas_num_threads - 1 : 0; i < num_threads - 1; i++){ atomic_store_queue(&thread_status[i].queue, (blas_queue_t *)0); thread_status[i].status = THREAD_STATUS_WAKEUP;