From: Eric Wong Date: Sun, 24 Sep 2023 21:08:22 +0000 (+0000) Subject: xap_helper.h: add missing headers and avoid reallocarray X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e49a6ebc0dfcb63fd6e9a79ea52be5c0f41b123;p=thirdparty%2Fpublic-inbox.git xap_helper.h: add missing headers and avoid reallocarray 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. --- diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index 377ff45ae..5f04316c9 100644 --- a/lib/PublicInbox/xap_helper.h +++ b/lib/PublicInbox/xap_helper.h @@ -35,7 +35,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -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;