Skip to content

Commit

Permalink
fix: avoid overflow in kqueue backend
Browse files Browse the repository at this point in the history
When there is more than 256 events, the `events` slice could overflow
when processing completions.
  • Loading branch information
Corendos committed Sep 10, 2024
1 parent dbe2291 commit a2d9b31
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/backend/kqueue.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a2d9b31

Please sign in to comment.