Remove MAX_THREADS.

This fixes a buffer overflow with more than 4 threads.
This commit is contained in:
Bill Currie 2015-08-14 10:57:51 +09:00
parent 8b9f513883
commit c71eccfb10

View file

@ -60,8 +60,6 @@
#include "vis.h"
#include "options.h"
#define MAX_THREADS 4
#ifdef USE_PTHREADS
pthread_attr_t threads_attrib;
pthread_rwlock_t *global_lock;
@ -528,11 +526,12 @@ static void
RunThreads (void *(*thread_func) (void *))
{
#ifdef USE_PTHREADS
pthread_t work_threads[MAX_THREADS + 1];
pthread_t *work_threads;
void *status;
int i;
if (options.threads > 1) {
work_threads = alloca ((options.threads + 1) * sizeof (pthread_t *));
working = calloc (options.threads, sizeof (int));
for (i = 0; i < options.threads; i++) {
if (pthread_create (&work_threads[i], &threads_attrib,