You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found some out-of-range patterns on xi-core-lib public APIs. All of these cases triggered when external crates use API of xi-core-lib.
As this issues looks quite obvious, I just list up the panic location. Please let me know if anyone need reproduce code for other cases.
Case-1
Thread '<unnamed>' panicked at 'slice index starts at 1 but ends at 0', xi-core-lib-0.3.0/src/selection.rs:137
/// Gets a slice of regions that intersect the given range. Regions that /// merely touch the range at the edges are also included, so it is the
/// caller's responsibility to further trim them, in particular to only
/// display one caret in the upstream/downstream cases.
///
/// Performance note: O(log n).
pub fn regions_in_range(&self, start: usize, end: usize) -> &[SelRegion] {
let first = self.search(start);
let mut last = self.search(end);
if last < self.regions.len() && self.regions[last].min() <= end {
last += 1;
}
&self.regions[first..last] // out-of-range!
}
Case-2
Thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', xi-core-lib-0.3.0/src/selection.rs:73
/// Collapse all selections into a single caret.
pub fn collapse(&mut self) {
self.regions.truncate(1);
self.regions[0].start = self.regions[0].end; // out-of-range!
}
Expected vs Actual
There should be range check via assert statement or should mention panic condition on docs.
The text was updated successfully, but these errors were encountered:
Details
I found some out-of-range patterns on xi-core-lib public APIs. All of these cases triggered when external crates use API of xi-core-lib.
As this issues looks quite obvious, I just list up the panic location. Please let me know if anyone need reproduce code for other cases.
Case-1
Case-2
Expected vs Actual
There should be range check via assert statement or should mention panic condition on docs.
The text was updated successfully, but these errors were encountered: