diff --git a/src/common/Thread.cpp b/src/common/Thread.cpp index 93e9cc96..3dfcad36 100644 --- a/src/common/Thread.cpp +++ b/src/common/Thread.cpp @@ -128,7 +128,6 @@ bool Thread::runAsThread(void* obj, void *(*startRoutine)(void *), thread_t* thr #else if (::pthread_create(&thread->thread, NULL, startRoutine, thread) != 0) { LogError(LOG_NET, "Error returned from pthread_create, err: %d", errno); - delete thread; return false; } #endif // defined(_WIN32) diff --git a/src/common/Thread.h b/src/common/Thread.h index 03ed8a3e..e101f445 100644 --- a/src/common/Thread.h +++ b/src/common/Thread.h @@ -100,6 +100,8 @@ public: /** * @brief Executes the specified start routine to run as a thread. + * On POSIX, if the thread fails to spawn for any reason, the caller should clean up the passed thread_t + * argument. * @param obj Instance of a object to pass to the threaded function. * @param startRoutine Represents the function that executes on a thread. * @param[out] thread Instance of the thread data.