From 2791c98c8ac8e029f9962593768ab8a1ff2aee5a Mon Sep 17 00:00:00 2001 From: Termina1 Date: Tue, 26 Nov 2024 14:54:17 +0200 Subject: [PATCH] fix removing ping from recs, in case slice is only contains ping --- sync.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sync.go b/sync.go index 09a33eb..40ddfb9 100644 --- a/sync.go +++ b/sync.go @@ -469,7 +469,11 @@ func (sync *Syncer) processPings(recs protocol.Records) protocol.Records { for i, rec := range recs { if protocol.Lit(rec) == 'P' { body, _ := protocol.Take('P', rec) - recs = append(recs[:i], recs[i+1:]...) + if len(recs) > i+1 { + recs = append(recs[:i], recs[i+1:]...) + } else { + recs = recs[:i] + } switch rdx.Snative(body) { case PingVal: sync.log.InfoCtx(sync.logCtx(context.Background()), "ping received")