From a05128bb052b7fdb759cb081781c5e24e8d14108 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 9 Dec 2024 18:51:09 +0100 Subject: [PATCH] Ensure we initialize thread IDs Signed-off-by: DL6ER --- src/tools/dhcp-discover.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tools/dhcp-discover.c b/src/tools/dhcp-discover.c index 73df2818e..c952009d7 100644 --- a/src/tools/dhcp-discover.c +++ b/src/tools/dhcp-discover.c @@ -765,7 +765,7 @@ int run_dhcp_discover(void) // Get interface names for available interfaces on this machine // and launch a thread for each one - pthread_t scanthread[2*MAXTHREADS]; + pthread_t scanthread[2*MAXTHREADS] = { 0 }; pthread_attr_t attr; // Initialize thread attributes object with default attribute values pthread_attr_init(&attr); @@ -832,8 +832,10 @@ int run_dhcp_discover(void) // Wait for all threads to join back with us for(tid--; tid > -1; tid--) { - pthread_join(scanthread[tid], NULL); - pthread_join(scanthread[2*tid], NULL); + if(scanthread[tid] != 0) + pthread_join(scanthread[tid], NULL); + if(scanthread[2*tid] != 0) + pthread_join(scanthread[2*tid], NULL); } // Free linked-list of interfaces on this client