From 45df9bcc39cd857a8a59db5f2e561550c1899e71 Mon Sep 17 00:00:00 2001 From: Gavin Hayes Date: Fri, 24 Mar 2023 15:18:12 -0400 Subject: [PATCH] APE fexecve, use static _Thread_local for env buffer to avoid using too much stack --- libc/calls/fexecve.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/calls/fexecve.c b/libc/calls/fexecve.c index 0a5791243..c2b5b208c 100644 --- a/libc/calls/fexecve.c +++ b/libc/calls/fexecve.c @@ -233,7 +233,7 @@ int fexecve(int fd, char *const argv[], char *const envp[]) { size_t numenvs; for (numenvs = 0; envp[numenvs];) ++numenvs; const size_t desenvs = min(500, max(numenvs + 1, 2)); - char *envs[500]; + static _Thread_local char *envs[500]; memcpy(envs, envp, numenvs * sizeof(char *)); envs[numenvs] = path; envs[numenvs + 1] = NULL;