From a2d9b3154f1e5ed463c9f2fb98a0d739057796ce Mon Sep 17 00:00:00 2001 From: Corentin Godeau Date: Tue, 10 Sep 2024 11:23:28 +0200 Subject: [PATCH] fix: avoid overflow in kqueue backend When there is more than 256 events, the `events` slice could overflow when processing completions. --- src/backend/kqueue.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/kqueue.zig b/src/backend/kqueue.zig index 834f916..456f64f 100644 --- a/src/backend/kqueue.zig +++ b/src/backend/kqueue.zig @@ -437,6 +437,9 @@ pub const Loop = struct { // Only resubmit if we aren't already active (in the queue) .rearm => if (!c_active) self.submissions.push(c), } + + // If we filled the events slice, we break to avoid overflow. + if (changes == events.len) break; } // Determine our next timeout based on the timers