From 9bbe15ebbc41533fa219d5b3017a26a75bc72731 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Wed, 5 Jun 2019 16:07:43 +0200 Subject: [PATCH] tests,w32: Fix thread creation in run-threaded * tests/run-threaded.c (create_thread): Check proper return value and not return value of CloseHandle. --- tests/run-threaded.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/run-threaded.c b/tests/run-threaded.c index 02524b22..7041da8d 100644 --- a/tests/run-threaded.c +++ b/tests/run-threaded.c @@ -56,12 +56,14 @@ static int mem_only; static void create_thread (THREAD_RET (*func) (void *), void *arg) { - running_threads++; - if (CloseHandle (CreateThread (NULL, 0, func, arg, 0, NULL))) + HANDLE hd = CreateThread (NULL, 0, func, arg, 0, NULL); + if (hd == INVALID_HANDLE_VALUE) { fprintf (stderr, "Failed to create thread!\n"); exit (1); } + running_threads++; + CloseHandle (hd); } #else