diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 71198b72c8..27184fb3c4 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -4786,13 +4786,10 @@ retry: /* * Queue a waiter to signal when this child dies. The wait will be handled - * automatically by an operating system thread pool. - * - * Note: use malloc instead of palloc, since it needs to be thread-safe. - * Struct will be free():d from the callback function that runs on a - * different thread. + * automatically by an operating system thread pool. The memory will be + * freed by a later call to waitpid(). */ - childinfo = malloc(sizeof(win32_deadchild_waitinfo)); + childinfo = palloc(sizeof(win32_deadchild_waitinfo)); if (!childinfo) ereport(FATAL, (errcode(ERRCODE_OUT_OF_MEMORY), @@ -6463,7 +6460,7 @@ waitpid(pid_t pid, int *exitstatus, int options) * Free struct that was allocated before the call to * RegisterWaitForSingleObject() */ - free(childinfo); + pfree(childinfo); return pid; }