From d3dd991e4e6f670c5daba9ba81aaa226b85eb200 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 18 Apr 2019 23:22:03 +0900 Subject: device: send: check packet length before freeing element --- device/send.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'device') diff --git a/device/send.go b/device/send.go index b4e23c7..ccb28da 100644 --- a/device/send.go +++ b/device/send.go @@ -601,6 +601,9 @@ func (peer *Peer) RoutineSequentialSender() { length := uint64(len(elem.packet)) err := peer.SendBuffer(elem.packet) + if len(elem.packet) != MessageKeepaliveSize { + peer.timersDataSent() + } device.PutMessageBuffer(elem.buffer) device.PutOutboundElement(elem) if err != nil { @@ -609,9 +612,6 @@ func (peer *Peer) RoutineSequentialSender() { } atomic.AddUint64(&peer.stats.txBytes, length) - if len(elem.packet) != MessageKeepaliveSize { - peer.timersDataSent() - } peer.keepKeyFreshSending() } } -- cgit v1.2.3