diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-02-17 08:46:11 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-02-17 08:46:11 -0500 |
commit | 0b46b082252935a57f960a2b461857b296b33d51 (patch) | |
tree | e293b80c1058be26957d9fb2d4b691a25d5b8095 /src/common/workqueue.c | |
parent | 7620c613e8bdaa34120136c91f71ae0cf8cb8506 (diff) | |
download | tor-0b46b082252935a57f960a2b461857b296b33d51.tar.gz tor-0b46b082252935a57f960a2b461857b296b33d51.zip |
Check thread count for negative; realloc->reallocarray
CID 1268069
Diffstat (limited to 'src/common/workqueue.c')
-rw-r--r-- | src/common/workqueue.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/common/workqueue.c b/src/common/workqueue.c index 823fb51cc9..c1bd6d4e8b 100644 --- a/src/common/workqueue.c +++ b/src/common/workqueue.c @@ -363,10 +363,14 @@ threadpool_queue_update(threadpool_t *pool, static int threadpool_start_threads(threadpool_t *pool, int n) { + if (n < 0) + return -1; + tor_mutex_acquire(&pool->lock); if (pool->n_threads < n) - pool->threads = tor_realloc(pool->threads, sizeof(workerthread_t*)*n); + pool->threads = tor_reallocarray(pool->threads, + sizeof(workerthread_t*), n); while (pool->n_threads < n) { void *state = pool->new_thread_state_fn(pool->new_thread_state_arg); |