From 9b9cacd93c540af4840e717dd85368eb4dcb58c8 Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Wed, 17 Dec 2025 10:05:20 +0800 Subject: [PATCH] Prevent removal when instances list is empty Add check to prevent removal from empty instances list. --- decrypt.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/decrypt.go b/decrypt.go index 5d31fec..553bc56 100644 --- a/decrypt.go +++ b/decrypt.go @@ -48,7 +48,13 @@ func (d *Dispatcher) AddInstance(inst *WrapperInstance) { func (d *Dispatcher) RemoveInstance(id string) { d.mu.Lock() defer d.mu.Unlock() + if len(d.Instances) == 0 { + return + } for i, inst := range d.Instances { + if inst == nil { + continue + } if inst.id == id { d.Instances = append(d.Instances[:i], d.Instances[i+1:]...) break