diff --git a/crates/voicevox_core/src/synthesizer.rs b/crates/voicevox_core/src/synthesizer.rs index 2e97fbe1c..73b4a6696 100644 --- a/crates/voicevox_core/src/synthesizer.rs +++ b/crates/voicevox_core/src/synthesizer.rs @@ -141,6 +141,9 @@ mod inner { frame_length = audio.frame_length, ); } + if range.start > range.end { + panic!("{range:?} is invalid because start > end",); + } let range = range.start..range.end + 2 * MARGIN; audio.internal_state.slice(ndarray::s![range, ..]) } diff --git a/crates/voicevox_core_python_api/src/lib.rs b/crates/voicevox_core_python_api/src/lib.rs index 3f3a51cb1..25eb2b33f 100644 --- a/crates/voicevox_core_python_api/src/lib.rs +++ b/crates/voicevox_core_python_api/src/lib.rs @@ -718,6 +718,12 @@ mod blocking { audio.frame_length(), ))); } + if start > end { + return Err(PyIndexError::new_err(format!( + "({}, {}) is invalid range because start > end", + start, end, + ))); + } let wav = &self .synthesizer .read()?