diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index f1dca2f25b..9008601fc4 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -6880,7 +6880,7 @@ pgstat_recv_replslot(PgStat_MsgReplSlot *msg, int len)
 	if (idx < 0)
 		return;
 
-	Assert(idx >= 0 && idx <= max_replication_slots);
+	Assert(idx >= 0 && idx < max_replication_slots);
 	if (msg->m_drop)
 	{
 		/* Remove the replication slot statistics with the given name */
@@ -7113,7 +7113,7 @@ pgstat_replslot_index(const char *name, bool create_it)
 
 	/* Register new slot */
 	memset(&replSlotStats[nReplSlotStats], 0, sizeof(PgStat_ReplSlotStats));
-	memcpy(&replSlotStats[nReplSlotStats].slotname, name, NAMEDATALEN);
+	strlcpy(&replSlotStats[nReplSlotStats].slotname, name, NAMEDATALEN);
 
 	return nReplSlotStats++;
 }
