From 5a1ce99d87438ad016f193ce367357d133e119df Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Sun, 27 Nov 2016 07:31:52 +0900 Subject: [PATCH] mcexec: fix number of threads not to exceed thread_data array --- executer/user/mcexec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index cf91d5b4..ccca4eb7 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -1550,7 +1550,7 @@ int main(int argc, char **argv) return 1; } - n_threads = ncpu + 1; + n_threads = ncpu; /* * XXX: keep thread_data ncpu sized despite that there are only @@ -1561,6 +1561,10 @@ int main(int argc, char **argv) * TODO: implement dynaic thread pool resizing. */ thread_data = (struct thread_data_s *)malloc(sizeof(struct thread_data_s) * (ncpu + 1)); + if (!thread_data) { + fprintf(stderr, "error: allocating thread pool data\n"); + return 1; + } memset(thread_data, '\0', sizeof(struct thread_data_s) * (ncpu + 1)); #if 0