diff --git a/src/common/util/thread.posix.c b/src/common/util/thread.posix.c index 8c4ce9d..bdaa1b1 100644 --- a/src/common/util/thread.posix.c +++ b/src/common/util/thread.posix.c @@ -76,14 +76,15 @@ thread_spawn(ThreadEntry entry, ThreadResult error_result) pthread_t handle; int error; if (!new_uninitialized(&th)) { + free(native_arg); return THREAD_NONE; } - error = pthread_create(&handle, NULL, &run_entry, native_arg); + error = pthread_create(&handle, NULL, &run_entry, native_arg); // calls free(native_arg) if error == 0 if (error) { errno = error; + free(native_arg); return delete_handle(th); } - assert(handle && "System allows 0 as thread id"); initialize_handle(&th, handle); return th; }