From 15128edde4f58e553a6bfa48715e5bae13f0ad65 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 1 Feb 2023 17:39:08 +0100 Subject: [PATCH] Fix assertions in clamping functions This was previously comparing against the buffer's length, so the `<` made sense. But this approach always allows events at time 0 even if the buffer is empty. --- src/wrapper/util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wrapper/util.rs b/src/wrapper/util.rs index c6c9a79a..02089800 100644 --- a/src/wrapper/util.rs +++ b/src/wrapper/util.rs @@ -69,7 +69,7 @@ pub fn clamp_input_event_timing(timing: u32, total_buffer_len: u32) -> u32 { let last_valid_index = total_buffer_len.saturating_sub(1); nih_debug_assert!( - timing < last_valid_index, + timing <= last_valid_index, "Input event is out of bounds, will be clamped to the buffer's size" ); @@ -83,7 +83,7 @@ pub fn clamp_output_event_timing(timing: u32, total_buffer_len: u32) -> u32 { let last_valid_index = total_buffer_len.saturating_sub(1); nih_debug_assert!( - timing < last_valid_index, + timing <= last_valid_index, "Output event is out of bounds, will be clamped to the buffer's size" );