Skip to content

Commit

Permalink
panic / raise error in invalid range such as start > end
Browse files Browse the repository at this point in the history
  • Loading branch information
Yosshi999 committed Nov 15, 2024
1 parent 255a3ef commit ce545a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/voicevox_core/src/synthesizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, ..])
}
Expand Down
6 changes: 6 additions & 0 deletions crates/voicevox_core_python_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?
Expand Down

0 comments on commit ce545a9

Please sign in to comment.