diff options
author | cypherpunks <cypherpunks@torproject.org> | 2015-07-07 10:17:32 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-07-21 13:57:53 -0400 |
commit | 3b3b447f75772cc5bbfb48a9e951482dca3c8c0d (patch) | |
tree | 124f0d99ff33ae70b041330a1d9a3dd8a41009f0 /src/common/compat_pthreads.c | |
parent | 2200d9d3f8b3830dff4c496d684147008bd38ace (diff) | |
download | tor-3b3b447f75772cc5bbfb48a9e951482dca3c8c0d.tar.gz tor-3b3b447f75772cc5bbfb48a9e951482dca3c8c0d.zip |
Fix some potential memory leaks in the thread pool code.
Diffstat (limited to 'src/common/compat_pthreads.c')
-rw-r--r-- | src/common/compat_pthreads.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c index 487f7e5851..b78ab3d871 100644 --- a/src/common/compat_pthreads.c +++ b/src/common/compat_pthreads.c @@ -64,13 +64,17 @@ spawn_func(void (*func)(void *), void *data) { pthread_t thread; tor_pthread_data_t *d; - if (PREDICT_UNLIKELY(!threads_initialized)) + if (PREDICT_UNLIKELY(!threads_initialized)) { tor_threads_init(); + } d = tor_malloc(sizeof(tor_pthread_data_t)); d->data = data; d->func = func; - if (pthread_create(&thread,&attr_detached,tor_pthread_helper_fn,d)) + if (pthread_create(&thread, &attr_detached, tor_pthread_helper_fn, d)) { + tor_free(d); return -1; + } + return 0; } |