Skip to content

Commit

Permalink
Fix possible division by zero error in RingBuffer.clear/removeFrontN.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Feb 13, 2025
1 parent 60f044f commit d641593
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/vibe/container/ringbuffer.d
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ struct RingBuffer(T, size_t N = 0, bool INITIALIZE = true) {
void removeFrontN(size_t n)
{
assert(length >= n);
if (!length) return;

static if (hasElaborateDestructor!T) {
foreach (i; 0 .. n)
destroy(m_buffer[mod(m_start + i)]);
Expand Down

0 comments on commit d641593

Please sign in to comment.