Skip to content

Commit bd01dc3

Browse files
authored
Merge pull request #4151 from martin-frbg/issue4101
Ensure that early calls to blas_set_num_threads will not overwrite unrelated memory
2 parents 5cb4f59 + 3bdcf32 commit bd01dc3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

driver/others/blas_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ void goto_set_num_threads(int num_threads) {
973973

974974
increased_threads = 1;
975975

976-
for(i = blas_num_threads - 1; i < num_threads - 1; i++){
976+
for(i = (blas_num_threads > 0) ? blas_num_threads - 1 : 0; i < num_threads - 1; i++){
977977

978978
atomic_store_queue(&thread_status[i].queue, (blas_queue_t *)0);
979979
thread_status[i].status = THREAD_STATUS_WAKEUP;

driver/others/blas_server_win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ void goto_set_num_threads(int num_threads)
568568
blas_server_avail = 1;
569569
}
570570

571-
for(i = blas_num_threads - 1; i < num_threads - 1; i++){
571+
for(i = (blas_num_threads > 0) ? blas_num_threads - 1 : 0; i < num_threads - 1; i++){
572572

573573
blas_threads[i] = CreateThread(NULL, 0,
574574
blas_thread_server, (void *)i,

0 commit comments

Comments
 (0)