Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+4-4
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)