diff options
author | Eric Wong <e@80x24.org> | 2023-09-24 21:08:22 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-09-24 23:14:24 +0000 |
commit | 9e49a6ebc0dfcb63fd6e9a79ea52be5c0f41b123 (patch) | |
tree | cb0d818cad39fe398522cb132f93ec0a9c2a0ac6 | |
parent | 0e0f4419064a5e0b7902bd09a4e4e055bde5db70 (diff) | |
download | public-inbox-9e49a6ebc0dfcb63fd6e9a79ea52be5c0f41b123.tar.gz |
These changes are necessary with glibc 2.17 and g++ 4.8.5 on CentOS 7.x. We don't have to worry about overflow with realloc(3) here since WORKER_MAX is only USHRT_MAX and sizeof(pid_t) is 4 bytes on every platform I've encountered.
-rw-r--r-- | lib/PublicInbox/xap_helper.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index 377ff45a..5f04316c 100644 --- a/lib/PublicInbox/xap_helper.h +++ b/lib/PublicInbox/xap_helper.h @@ -35,7 +35,10 @@ #include <limits.h> #include <search.h> #include <signal.h> +#include <stddef.h> +#include <stdint.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <sysexits.h> #include <unistd.h> @@ -1084,9 +1087,9 @@ static void do_sigttin(void) warnx("workers cannot exceed %zu", (size_t)WORKER_MAX); return; } - void *p = reallocarray(worker_pids, nworker + 1, sizeof(pid_t)); + void *p = realloc(worker_pids, (nworker + 1) * sizeof(pid_t)); if (!p) { - warn("reallocarray"); + warn("realloc worker_pids"); } else { worker_pids = (pid_t *)p; worker_pids[nworker++] = 0; |