From 847af03dc72c8042bae6c88ec0f6750484136870 Mon Sep 17 00:00:00 2001
From: Michael Sippel <micha@fragmental.art>
Date: Sun, 8 Dec 2024 19:35:58 +0100
Subject: [PATCH] delay: avoid div by zero in `delay_set_duration()`

---
 delay.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/delay.c b/delay.c
index 91236c9..f9a6ea8 100644
--- a/delay.c
+++ b/delay.c
@@ -30,7 +30,9 @@ void delay_set_time(
     }
 
     delay->duration = new_duration;
-    delay->buf_idx %= new_duration;
+    if( new_duration > 0 ) {
+        delay->buf_idx %= new_duration;
+    }
 }
 
 void delay_process(