From 3ef77b0c1ad12fbade6ba53a28f15539392cf8ea Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 14 Sep 2020 10:32:32 +0700 Subject: [PATCH] add an assertion that bytes_in_flight never becomes negative --- internal/ackhandler/sent_packet_handler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index d970b61fe..e7b0c293e 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -133,6 +133,9 @@ func (h *sentPacketHandler) DropPackets(encLevel protocol.EncryptionLevel) { func (h *sentPacketHandler) removeFromBytesInFlight(p *Packet) { if p.includedInBytesInFlight { + if p.Length > h.bytesInFlight { + panic("negative bytes_in_flight") + } h.bytesInFlight -= p.Length p.includedInBytesInFlight = false }