Skip to content

Commit

Permalink
Access to m_recyclingCount after null check (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Morb0 authored Aug 24, 2023
1 parent 78aa82c commit 14364d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lidgren.Network/NetReliableSenderChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,16 @@ private void DestoreMessage(double now, int storeIndex, out bool resetTimeout)

var storedMessage = srm.Message;

// on each destore; reduce recyclingcount so that when all instances are destored, the outgoing message can be recycled
Interlocked.Decrement(ref storedMessage.m_recyclingCount);
#if DEBUG
if (storedMessage == null)
throw new NetException("m_storedMessages[" + storeIndex + "].Message is null; sent " + m_storedMessages[storeIndex].NumSent + " times, last time " + (NetTime.Now - m_storedMessages[storeIndex].LastSent) + " seconds ago");
#else
if (storedMessage != null)
{
#endif
// on each destore; reduce recyclingcount so that when all instances are destored, the outgoing message can be recycled
Interlocked.Decrement(ref storedMessage.m_recyclingCount);

if (storedMessage.m_recyclingCount <= 0)
m_connection.m_peer.Recycle(storedMessage);

Expand Down

0 comments on commit 14364d2

Please sign in to comment.