From e65fe614b7eef93ced755f41753c27b499524249 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sun, 15 Sep 2024 04:24:20 -0700 Subject: [PATCH] Fix shocking memory leak on Windows Spawning processes would leak lots of memory, due to a missing free call in ntspawn(). Our tooling never caught this since ntspawn() must use the WIN32 memory allocator. It means every time posix_spawn, fork, or execve got called, we would leak 162kb of memory. I'm proud to say that's fixed --- libc/calls/ntspawn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libc/calls/ntspawn.c b/libc/calls/ntspawn.c index ba949b71d..b0887c2b6 100644 --- a/libc/calls/ntspawn.c +++ b/libc/calls/ntspawn.c @@ -238,6 +238,7 @@ textwindows int ntspawn(struct NtSpawnArgs *args) { BLOCK_SIGNALS; if ((sb = ntspawn_malloc(sizeof(*sb)))) { rc = ntspawn2(args, sb); + ntspawn_free(sb); } else { rc = -1; }