Skip to content

Commit 2cc6889

Browse files
committed
Ensure our lengths use isize and not usize for checks.
1 parent 9013c83 commit 2cc6889

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fast-float2"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
authors = ["Ivan Smirnov <[email protected]>", "Alex Huszagh <[email protected]>"]
55
repository = "https://github.com/Alexhuszagh/fast-float-rust"
66
documentation = "https://docs.rs/fast-float2"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This crate provides a super-fast decimal number parser from strings into floats.
1212

1313
```toml
1414
[dependencies]
15-
fast-float2 = "0.2.2"
15+
fast-float2 = "0.2.3"
1616
```
1717

1818
There are no dependencies and the crate can be used in a no_std context by disabling the "std" feature.

src/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ impl<'a> AsciiStr<'a> {
1818
}
1919
}
2020

21-
pub fn len(&self) -> usize {
22-
self.end as usize - self.ptr as usize
21+
pub fn len(&self) -> isize {
22+
self.end as isize - self.ptr as isize
2323
}
2424

2525
/// # Safety
@@ -28,7 +28,7 @@ impl<'a> AsciiStr<'a> {
2828
#[inline]
2929
pub unsafe fn step_by(&mut self, n: usize) -> &mut Self {
3030
debug_assert!(
31-
n <= self.len(),
31+
n < isize::MAX as usize && n as isize <= self.len(),
3232
"buffer overflow: stepping by greater than our buffer length."
3333
);
3434
// SAFETY: Safe if `n <= self.len()`

0 commit comments

Comments
 (0)