@@ -649,6 +649,10 @@ receive_array(SHMRequest request, Size item_size, Size *count)
649
649
pgws_collector_hdr -> request = request ;
650
650
LockRelease (& collectorTag ,ExclusiveLock , false);
651
651
652
+ /*
653
+ * Check that the collector was started to avoid NULL
654
+ * pointer dereference.
655
+ */
652
656
if (!pgws_collector_hdr -> latch )
653
657
ereport (ERROR , (errcode (ERRCODE_INTERNAL_ERROR ),
654
658
errmsg ("pg_wait_sampling collector wasn't started" )));
@@ -819,6 +823,14 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
819
823
pgws_collector_hdr -> request = PROFILE_RESET ;
820
824
LockRelease (& collectorTag ,ExclusiveLock , false);
821
825
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
+
822
834
SetLatch (pgws_collector_hdr -> latch );
823
835
824
836
LockRelease (& queueTag ,ExclusiveLock , false);