Commit ed6329cf authored by Tom Lane's avatar Tom Lane

Avoid memcpy() with same source and destination in pgstat_recv_replslot.

Same type of issue as in commit 53d4f5fe and earlier fixes; also
found by apparently-more-picky-than-the-buildfarm valgrind testing.
This one is an oversight in commit 98681675.  Since that's new in
HEAD, no need for a back-patch.
parent 11072e86
...@@ -6916,15 +6916,15 @@ pgstat_recv_replslot(PgStat_MsgReplSlot *msg, int len) ...@@ -6916,15 +6916,15 @@ pgstat_recv_replslot(PgStat_MsgReplSlot *msg, int len)
return; return;
/* it must be a valid replication slot index */ /* it must be a valid replication slot index */
Assert(idx >= 0 && idx < max_replication_slots); Assert(idx < nReplSlotStats);
if (msg->m_drop) if (msg->m_drop)
{ {
/* Remove the replication slot statistics with the given name */ /* Remove the replication slot statistics with the given name */
memcpy(&replSlotStats[idx], &replSlotStats[nReplSlotStats - 1], if (idx < nReplSlotStats - 1)
sizeof(PgStat_ReplSlotStats)); memcpy(&replSlotStats[idx], &replSlotStats[nReplSlotStats - 1],
sizeof(PgStat_ReplSlotStats));
nReplSlotStats--; nReplSlotStats--;
Assert(nReplSlotStats >= 0);
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment