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

Panic on underflow #3

Closed
casey opened this issue Apr 22, 2019 · 2 comments
Closed

Panic on underflow #3

casey opened this issue Apr 22, 2019 · 2 comments

Comments

@casey
Copy link
Contributor

casey commented Apr 22, 2019

I think that there are scenarios where this subtraction can underflow and panic:

if let Some(Difference::Rem(removed)) = diffs.get(i - 1) {

The line is here:

if let Some(Difference::Rem(removed)) = diffs.get(i - 1) {

I'm sorry for not providing a good reproduction case, I got a crash but couldn't stop to come up with a minimal reproduction

@CAD97
Copy link
Owner

CAD97 commented Apr 24, 2019

If the text starts with an Add then the subtraction will underflow, thus panicking in debug mode. It will work properly in release mode. I can't patch this for a bit (I'm super busy rn), but the simple fix is just to wrapping subtract. If you send me a PR to fix it I'll pull it and push a new version sooner than I'd get to it otherwise.

@CAD97
Copy link
Owner

CAD97 commented May 17, 2019

Fixed by #4 and released as v0.2.2! 🎉

@CAD97 CAD97 closed this as completed May 17, 2019
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

No branches or pull requests

2 participants