From 9a75c19591bf8c1bb657978ad6c4add639daca23 Mon Sep 17 00:00:00 2001 From: Sofia Kopikova Date: Fri, 4 Oct 2024 13:48:49 +0300 Subject: [PATCH] PGPRO-11098 add null-pointer check to ptrack_set_init_lsn() function When ptrack extension is added to shared_preload_libraries, but ptrack.map size is 0, we may encounter segmantation fault when calling ptrack_backup_checkpoint_request_hook() function. This commit adds additional null-pointer checks to ptrack_set_init_lsn() function called by ptrack_backup_checkpoint_request_hook() to avoid this segfault --- engine.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engine.c b/engine.c index f0c2f9b..dfd7c84 100644 --- a/engine.c +++ b/engine.c @@ -659,6 +659,10 @@ XLogRecPtr ptrack_set_init_lsn(void) { XLogRecPtr new_lsn; + + if (ptrack_map_size == 0 || ptrack_map == NULL) + return InvalidXLogRecPtr; + if (RecoveryInProgress()) new_lsn = GetXLogReplayRecPtr(NULL); else