]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-test: test-subprocess - Free subprocess before forking
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 18 Mar 2022 07:41:37 +0000 (09:41 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 18 Mar 2022 07:44:14 +0000 (09:44 +0200)
Otherwise it'll leak memory.

Broken in 34bdfdcbc7e3b374a219732329b6ce6d84a7666e

src/lib-test/test-subprocess.c

index 584e7b3b70af233c59204e0bd43d81b7bbd6b7e2..eeaae801b3693ea160f6738bf28bb304a86e7140 100644 (file)
@@ -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);