Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subtraction underflow bug #906

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bug fixes
---------

* (Fuzzing) An integer-overflow bug from an inclusive range in the bits iterator is fixed.
* (Fuzzing) An integer-underflow bug from an inclusive range is fixed.

Enhancements
------------
Expand Down
2 changes: 2 additions & 0 deletions src/eval/target.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Type to hold a mutable reference to the target of an evaluation.

use crate::{Dynamic, EvalAltResult, Position, RhaiError, RhaiResultOf};

Check warning on line 3 in src/eval/target.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_time,no_function,no_float,no_position,no_inde...

unused import: `EvalAltResult`

Check warning on line 3 in src/eval/target.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,sync,no_time,no_function,no_float,no_position,no...

unused import: `EvalAltResult`

Check warning on line 3 in src/eval/target.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_function,serde,metadata,internals,debugging, ...

unused import: `EvalAltResult`

Check warning on line 3 in src/eval/target.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, --features testing-environ,no_closure,serde,metadata,internals,debugging, s...

unused import: `EvalAltResult`
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{
Expand Down Expand Up @@ -404,6 +404,8 @@
let ve = if *exclusive {
let end = if *end > n { n } else { *end };
s.chars().skip(end)
} else if n == 0 {
s.chars().skip(usize::MAX)
} else {
let end = if *end >= n { n - 1 } else { *end };
s.chars().skip(end + 1)
Expand Down
Loading