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

Tighten up saturating_ math checks #1254

Merged
merged 4 commits into from
Nov 28, 2023
Merged

Conversation

jayz22
Copy link
Contributor

@jayz22 jayz22 commented Nov 27, 2023

What

Resolves #1141

Several places benefit from changing saturating_ to checked_ math:

  • saturating_add(_mul) on u32, saturation would be within possibility
  • Some saturating_sub saturation would mean actual error, e.g index out of bound

In both cases, changing to checked_ version means overflow errors are caught sooner.

Why

[TODO: Why this change is being made. Include any context required to understand the why.]

Known limitations

[TODO or N/A]

soroban-env-host/src/budget/limits.rs Outdated Show resolved Hide resolved
soroban-env-host/src/host.rs Outdated Show resolved Hide resolved
soroban-env-host/src/host/ledger_info_helper.rs Outdated Show resolved Hide resolved
soroban-env-host/src/storage.rs Outdated Show resolved Hide resolved
@dmkozh dmkozh enabled auto-merge November 28, 2023 18:12
@dmkozh dmkozh added this pull request to the merge queue Nov 28, 2023
Merged via the queue into stellar:main with commit 8f7445b Nov 28, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saturating math -> checked math?
3 participants