summaryrefslogtreecommitdiff
path: root/src/backend/replication/walsender.c
diff options
context:
space:
mode:
authorAlvaro Herrera2020-05-15 23:59:29 +0000
committerAlvaro Herrera2020-05-16 00:00:52 +0000
commit1d3743023ef8fa665902e791b0d52e9a1ab419cb (patch)
tree7cf3a1fb6c6c2cf21a342beaf33cc662af4d01ec /src/backend/replication/walsender.c
parent14a91010912632cae322b06fce0425faedcf7353 (diff)
Fix walsender error cleanup code
In commit 850196b610d2 I (Álvaro) failed to handle the case of walsender shutting down on an error before setting up its 'xlogreader' pointer; the error handling code dereferences the pointer, causing a crash. Fix by testing the pointer before trying to dereference it. Kyotaro authored the code fix; I adopted Nathan's test case to be used by the TAP tests and added the necessary PostgresNode change. Reported-by: Nathan Bossart <[email protected]> Author: Kyotaro Horiguchi <[email protected]> Author: Álvaro Herrera <[email protected]> Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/replication/walsender.c')
-rw-r--r--src/backend/replication/walsender.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index a4ca8daea77..86847cbb54f 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -315,7 +315,7 @@ WalSndErrorCleanup(void)
ConditionVariableCancelSleep();
pgstat_report_wait_end();
- if (xlogreader->seg.ws_file >= 0)
+ if (xlogreader != NULL && xlogreader->seg.ws_file >= 0)
wal_segment_close(xlogreader);
if (MyReplicationSlot != NULL)