Skip to content

Commit 4a0e34d

Browse files
review comments
1 parent e6d1973 commit 4a0e34d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/inet/UDPEndPointImplLwIP.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,17 @@ void UDPEndPointImplLwIP::LwIPReceiveUDPMessage(void * arg, struct udp_pcb * pcb
393393
// Capture the instance ID to validate this is still the same endpoint instance
394394
uint32_t expectedInstanceId = ep->mInstanceId.load();
395395
CHIP_ERROR err = ep->GetSystemLayer().ScheduleLambda(
396-
[ep, pcb, expectedInstanceId, p = System::LwIPPacketBufferView::UnsafeGetLwIPpbuf(buf), pktInfo = pktInfo.get()] {
396+
[ep, expectedInstanceId, p = System::LwIPPacketBufferView::UnsafeGetLwIPpbuf(buf), pktInfo = pktInfo.get()] {
397397
// Critical check: Verify this lambda is for the correct endpoint instance
398398
// by comparing the instance ID. If they don't match, the endpoint was
399-
// deleted and recreated at the same memory address.
399+
// deleted and new endpoint wascreated at the same memory address.
400400
if (ep->mInstanceId.load() != expectedInstanceId)
401401
{
402402
// This is a stale lambda for a previously deleted endpoint.
403403
// The memory was reused for a new endpoint with different instance ID.
404+
// Note: We don't decrement mDelayReleaseCount here because:
405+
// - The original endpoint's count is gone with the deleted endpoint
406+
// - The new endpoint's count should not be decremented (it never had this packet)
404407
pbuf_free(p);
405408
return;
406409
}

0 commit comments

Comments
 (0)