Skip to content

Commit ed6329c

Browse files
committed
Avoid memcpy() with same source and destination in pgstat_recv_replslot.
Same type of issue as in commit 53d4f5f and earlier fixes; also found by apparently-more-picky-than-the-buildfarm valgrind testing. This one is an oversight in commit 9868167. Since that's new in HEAD, no need for a back-patch.
1 parent 11072e8 commit ed6329c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6916,15 +6916,15 @@ pgstat_recv_replslot(PgStat_MsgReplSlot *msg, int len)
69166916
return;
69176917

69186918
/* it must be a valid replication slot index */
6919-
Assert(idx >= 0 && idx < max_replication_slots);
6919+
Assert(idx < nReplSlotStats);
69206920

69216921
if (msg->m_drop)
69226922
{
69236923
/* Remove the replication slot statistics with the given name */
6924-
memcpy(&replSlotStats[idx], &replSlotStats[nReplSlotStats - 1],
6925-
sizeof(PgStat_ReplSlotStats));
6924+
if (idx < nReplSlotStats - 1)
6925+
memcpy(&replSlotStats[idx], &replSlotStats[nReplSlotStats - 1],
6926+
sizeof(PgStat_ReplSlotStats));
69266927
nReplSlotStats--;
6927-
Assert(nReplSlotStats >= 0);
69286928
}
69296929
else
69306930
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy