From 01402bdba2977a3cc2f86e92d460e47e207e5219 Mon Sep 17 00:00:00 2001 From: Alexey Dolotov Date: Sat, 28 Mar 2026 22:31:47 +0300 Subject: [PATCH] fix: prevent index out of range panic on 32-bit platforms On 32-bit architectures (e.g. ARM7), int is 32 bits wide. Casting a uint32 hash value to int can overflow, producing a negative number. Go's modulo operator preserves the sign, so the channel index can become -1, causing a panic. Perform the modulo in uint32 space before indexing to ensure the result is always non-negative. Fixes #413 --- events/event_stream.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/event_stream.go b/events/event_stream.go index b71db4c..516f77e 100644 --- a/events/event_stream.go +++ b/events/event_stream.go @@ -38,7 +38,7 @@ func (e EventStream) Send(ctx context.Context, evt mtglib.Event) { select { case <-ctx.Done(): case <-e.ctx.Done(): - case e.chans[int(chanNo)%len(e.chans)] <- evt: + case e.chans[chanNo%uint32(len(e.chans))] <- evt: } }