From 049d7b96a1ca2cae5b0894dbd3567c0157766e19 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Tue, 15 Apr 2014 11:02:07 -0400
Subject: [PATCH] ringbuffer: fix modulo 0

Refs #45343
---
 daemon/src/audio/ringbuffer.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/daemon/src/audio/ringbuffer.cpp b/daemon/src/audio/ringbuffer.cpp
index b6202e565d..8b3c21d963 100644
--- a/daemon/src/audio/ringbuffer.cpp
+++ b/daemon/src/audio/ringbuffer.cpp
@@ -283,7 +283,7 @@ RingBuffer::discard(size_t toDiscard, const std::string &call_id)
 {
     std::unique_lock<std::mutex> l(lock_);
 
-    size_t buffer_size = buffer_.frames();
+    const size_t buffer_size = buffer_.frames();
     if (buffer_size == 0)
         return 0;
 
@@ -300,6 +300,9 @@ size_t
 RingBuffer::discard(size_t toDiscard)
 {
     const size_t buffer_size = buffer_.frames();
+    if (buffer_size == 0)
+        return 0;
+
     for (auto & r : readpointers_) {
         size_t dst = (r.second + buffer_size - endPos_) % buffer_size;
         if (dst < toDiscard) {
-- 
GitLab