Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pg_wait_sampling.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ receive_array(SHMRequest request, Size item_size, Size *count)
pgws_collector_hdr->request = request;
LockRelease(&collectorTag, ExclusiveLock, false);

/*
* Check that the collector was started to avoid NULL
* pointer dereference.
*/
if (!pgws_collector_hdr->latch)
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
errmsg("pg_wait_sampling collector wasn't started")));
Expand Down Expand Up @@ -819,6 +823,14 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
pgws_collector_hdr->request = PROFILE_RESET;
LockRelease(&collectorTag, ExclusiveLock, false);

/*
* Check that the collector was started to avoid NULL
* pointer dereference.
*/
if (!pgws_collector_hdr->latch)
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
errmsg("pg_wait_sampling collector wasn't started")));

SetLatch(pgws_collector_hdr->latch);

LockRelease(&queueTag, ExclusiveLock, false);
Expand Down