mirror of
https://github.com/postgres/postgres.git
synced 2025-06-20 15:22:23 +03:00
Fix user-after-free bug.
Introduced by commit aea5d29836
.
Patch from Amit Kapila. Issue discovered independently by Amit Kapila
and Ashutosh Sharma.
This commit is contained in:
@ -440,12 +440,14 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur)
|
|||||||
{
|
{
|
||||||
RegisteredBgWorker *rw;
|
RegisteredBgWorker *rw;
|
||||||
BackgroundWorkerSlot *slot;
|
BackgroundWorkerSlot *slot;
|
||||||
|
int notify_pid;
|
||||||
|
|
||||||
rw = slist_container(RegisteredBgWorker, rw_lnode, cur->cur);
|
rw = slist_container(RegisteredBgWorker, rw_lnode, cur->cur);
|
||||||
|
|
||||||
Assert(rw->rw_shmem_slot < max_worker_processes);
|
Assert(rw->rw_shmem_slot < max_worker_processes);
|
||||||
slot = &BackgroundWorkerData->slot[rw->rw_shmem_slot];
|
slot = &BackgroundWorkerData->slot[rw->rw_shmem_slot];
|
||||||
slot->pid = rw->rw_pid;
|
slot->pid = rw->rw_pid;
|
||||||
|
notify_pid = rw->rw_worker.bgw_notify_pid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this worker is slated for deregistration, do that before notifying
|
* If this worker is slated for deregistration, do that before notifying
|
||||||
@ -458,8 +460,8 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur)
|
|||||||
rw->rw_worker.bgw_restart_time == BGW_NEVER_RESTART)
|
rw->rw_worker.bgw_restart_time == BGW_NEVER_RESTART)
|
||||||
ForgetBackgroundWorker(cur);
|
ForgetBackgroundWorker(cur);
|
||||||
|
|
||||||
if (rw->rw_worker.bgw_notify_pid != 0)
|
if (notify_pid != 0)
|
||||||
kill(rw->rw_worker.bgw_notify_pid, SIGUSR1);
|
kill(notify_pid, SIGUSR1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user