Skip to content

Commit 7f6fa29

Browse files
committed
Fix user-after-free bug.
Introduced by commit aea5d29. Patch from Amit Kapila. Issue discovered independently by Amit Kapila and Ashutosh Sharma.
1 parent e434ad3 commit 7f6fa29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/postmaster/bgworker.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,14 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur)
440440
{
441441
RegisteredBgWorker *rw;
442442
BackgroundWorkerSlot *slot;
443+
int notify_pid;
443444

444445
rw = slist_container(RegisteredBgWorker, rw_lnode, cur->cur);
445446

446447
Assert(rw->rw_shmem_slot < max_worker_processes);
447448
slot = &BackgroundWorkerData->slot[rw->rw_shmem_slot];
448449
slot->pid = rw->rw_pid;
450+
notify_pid = rw->rw_worker.bgw_notify_pid;
449451

450452
/*
451453
* If this worker is slated for deregistration, do that before notifying
@@ -458,8 +460,8 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur)
458460
rw->rw_worker.bgw_restart_time == BGW_NEVER_RESTART)
459461
ForgetBackgroundWorker(cur);
460462

461-
if (rw->rw_worker.bgw_notify_pid != 0)
462-
kill(rw->rw_worker.bgw_notify_pid, SIGUSR1);
463+
if (notify_pid != 0)
464+
kill(notify_pid, SIGUSR1);
463465
}
464466

465467
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy