From: Aki Tuomi Date: Fri, 18 Mar 2022 07:41:37 +0000 (+0200) Subject: lib-test: test-subprocess - Free subprocess before forking X-Git-Tag: 2.3.19~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f95da1fa2f0e2a47e2911e84861add17f2c21793;p=thirdparty%2Fdovecot%2Fcore.git lib-test: test-subprocess - Free subprocess before forking Otherwise it'll leak memory. Broken in 34bdfdcbc7e3b374a219732329b6ce6d84a7666e --- 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);