From 7e116dfb29faaff1ff557bfaddf057debe601197 Mon Sep 17 00:00:00 2001 From: Niko Date: Wed, 10 Sep 2025 15:28:40 -0700 Subject: [PATCH] Fix UB in WhisperVadSegments --- src/whisper_vad.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/whisper_vad.rs b/src/whisper_vad.rs index 9c965ca..58a8122 100644 --- a/src/whisper_vad.rs +++ b/src/whisper_vad.rs @@ -251,24 +251,24 @@ impl WhisperVadSegments { } pub fn index_in_bounds(&self, idx: c_int) -> bool { - idx < 0 || idx > self.segment_count + idx >= 0 && idx < self.segment_count } /// Return the start timestamp of this segment in centiseconds (10s of milliseconds). pub fn get_segment_start_timestamp(&self, idx: c_int) -> Option { if self.index_in_bounds(idx) { - None - } else { Some(unsafe { whisper_vad_segments_get_segment_t0(self.ptr, idx) }) + } else { + None } } /// Return the end timestamp of this segment in centiseconds (10s of milliseconds). pub fn get_segment_end_timestamp(&self, idx: c_int) -> Option { if self.index_in_bounds(idx) { - None - } else { Some(unsafe { whisper_vad_segments_get_segment_t1(self.ptr, idx) }) + } else { + None } }