From 4e7bce72d2cea89d97746ababff967f52f63cb2d Mon Sep 17 00:00:00 2001 From: simon therriault Date: Fri, 1 Sep 2023 10:41:33 -0400 Subject: [PATCH] - Fixing crash in UDP messaging meshing when too many endpoints are found #rb jason.walter #jira [CL 27555234 by simon therriault in ue5-main branch] --- .../Private/Transport/UdpMessageProcessor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageProcessor.cpp b/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageProcessor.cpp index 85f0d43da3cc..ee26e48d9cfc 100644 --- a/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageProcessor.cpp +++ b/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageProcessor.cpp @@ -994,15 +994,15 @@ void FUdpMessageProcessor::SendKnownNodesToKnownNodes() const int32 NumEndpointsCanSend = (UDP_MESSAGING_SEGMENT_SIZE - sizeof(FUdpMessageSegment::FHeader)) / (sizeof(FIPv4Endpoint) + sizeof(FGuid)) - 1; if (KnownEndpointsView.Num() > NumEndpointsCanSend) { - UE_LOG(LogUdpMessaging, Warning, TEXT("FUdpMessageProcessor::SendKnownNodesToKnownNodes large number of endpoints to share for meshing udp transport.")); + UE_LOG(LogUdpMessaging, Warning, TEXT("FUdpMessageProcessor::SendKnownNodesToKnownNodes large number of endpoints (%d) to share for meshing udp transport."), KnownEndpointsView.Num()); } int32 Index = 0; while (Index < KnownEndpointsView.Num()) { - const uint32 NextBlockIndex = FMath::Min(Index + NumEndpointsCanSend, KnownEndpointsView.Num()); - TArrayView SlicedEndpointView = KnownEndpointsView.Slice(Index, NextBlockIndex); - TArrayView SlicedIdView = KnownIdView.Slice(Index, NextBlockIndex); + const uint32 NextBlockItemCount = FMath::Min(Index + NumEndpointsCanSend, KnownEndpointsView.Num() - Index); + TArrayView SlicedEndpointView = KnownEndpointsView.Slice(Index, NextBlockItemCount); + TArrayView SlicedIdView = KnownIdView.Slice(Index, NextBlockItemCount); OutEndpoints = SlicedEndpointView; OutIds = SlicedIdView;