From f95da1fa2f0e2a47e2911e84861add17f2c21793 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Fri, 18 Mar 2022 09:41:37 +0200 Subject: [PATCH] lib-test: test-subprocess - Free subprocess before forking Otherwise it'll leak memory. Broken in 34bdfdcbc7e3b374a219732329b6ce6d84a7666e --- src/lib-test/test-subprocess.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib-test/test-subprocess.c b/src/lib-test/test-subprocess.c index 584e7b3b70..eeaae801b3 100644 --- a/src/lib-test/test-subprocess.c +++ b/src/lib-test/test-subprocess.c @@ -95,6 +95,9 @@ void test_subprocess_fork(int (*func)(void *context), void *context, if ((subprocess->pid = fork()) == (pid_t)-1) i_fatal("test: sub-process: fork() failed: %m"); if (subprocess->pid == 0) { + /* cannot include this in the list to avoid accidental + * kill of PID 0, so just free it here explicitly. */ + i_free(subprocess); test_subprocess_free_all(); test_subprocess_child(func, context, continue_test); -- 2.47.3