From c64fadef4b51b75e1a66848cadf145154ac200fb Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Mar 2024 14:13:54 +0800 Subject: [PATCH] Reason is optional --- goodbye.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/goodbye.go b/goodbye.go index bda1785..f87731c 100644 --- a/goodbye.go +++ b/goodbye.go @@ -133,7 +133,11 @@ func (g *Goodbye) Header() Header { // MarshalSize returns the size of the packet once marshaled func (g *Goodbye) MarshalSize() int { srcsLength := len(g.Sources) * ssrcLength - reasonLength := len(g.Reason) + 1 + // reason is optional + reasonLength := len(g.Reason) + if reasonLength > 0 { + reasonLength++ + } l := headerLength + srcsLength + reasonLength