aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-12-20 12:38:32 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-12-20 12:38:32 -0500
commited6329cfa975a13c58c44676464585cda5d317b3 (patch)
treedb0971aab3a8ca87ba62ad3bbc74e0597b1daaaf
parent11072e86939d2f5ca0a97c709b46f29ea8b57590 (diff)
downloadpostgresql-ed6329cfa975a13c58c44676464585cda5d317b3.tar.gz
postgresql-ed6329cfa975a13c58c44676464585cda5d317b3.zip
Avoid memcpy() with same source and destination in pgstat_recv_replslot.
Same type of issue as in commit 53d4f5fef and earlier fixes; also found by apparently-more-picky-than-the-buildfarm valgrind testing. This one is an oversight in commit 986816750. Since that's new in HEAD, no need for a back-patch.
-rw-r--r--src/backend/postmaster/pgstat.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 6b60f293e94..d87d9d06ee2 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -6916,15 +6916,15 @@ pgstat_recv_replslot(PgStat_MsgReplSlot *msg, int len)
return;
/* it must be a valid replication slot index */
- Assert(idx >= 0 && idx < max_replication_slots);
+ Assert(idx < nReplSlotStats);
if (msg->m_drop)
{
/* Remove the replication slot statistics with the given name */
- memcpy(&replSlotStats[idx], &replSlotStats[nReplSlotStats - 1],
- sizeof(PgStat_ReplSlotStats));
+ if (idx < nReplSlotStats - 1)
+ memcpy(&replSlotStats[idx], &replSlotStats[nReplSlotStats - 1],
+ sizeof(PgStat_ReplSlotStats));
nReplSlotStats--;
- Assert(nReplSlotStats >= 0);
}
else
{