Skip to content

Commit 8427f4a

Browse files
authored
Merge pull request #100 from valeriy-zainullin/master
Check that collector has started in pg_wait_sampling_reset_profile.
2 parents fafeda0 + 930a67a commit 8427f4a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pg_wait_sampling.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,10 @@ receive_array(SHMRequest request, Size item_size, Size *count)
649649
pgws_collector_hdr->request = request;
650650
LockRelease(&collectorTag, ExclusiveLock, false);
651651

652+
/*
653+
* Check that the collector was started to avoid NULL
654+
* pointer dereference.
655+
*/
652656
if (!pgws_collector_hdr->latch)
653657
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
654658
errmsg("pg_wait_sampling collector wasn't started")));
@@ -819,6 +823,14 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
819823
pgws_collector_hdr->request = PROFILE_RESET;
820824
LockRelease(&collectorTag, ExclusiveLock, false);
821825

826+
/*
827+
* Check that the collector was started to avoid NULL
828+
* pointer dereference.
829+
*/
830+
if (!pgws_collector_hdr->latch)
831+
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
832+
errmsg("pg_wait_sampling collector wasn't started")));
833+
822834
SetLatch(pgws_collector_hdr->latch);
823835

824836
LockRelease(&queueTag, ExclusiveLock, false);

0 commit comments

Comments
 (0)