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 potential overflow issue #521

Merged
merged 1 commit into from
Nov 19, 2024
Merged

Conversation

0xh3rman
Copy link
Contributor

Hi Orca team,

I found a potential overflow when I was trying to calculate quote for SOL -> USDC using orca_whirlpools_core in debug mode.

More specifically, next_start_tick_index might be i32::MAX and current_start_tick_index might be negative value like -13728, Rust would panic with error: attempt to subtract with overflow

This fix uses short-circuit evaluation to work around this check, maybe a more explicit fix is to convert next_start_tick_index to i64?

@wjthieme
Copy link
Member

Thanks for the contribution! We had this fix included in #428 but I can include this separately today

@wjthieme wjthieme enabled auto-merge (squash) November 19, 2024 15:24
@wjthieme wjthieme merged commit 4427688 into orca-so:main Nov 19, 2024
6 checks passed
@0xh3rman
Copy link
Contributor Author

Thanks for the quick respond @wjthieme, going to point it to main until 428 is merged

@wjthieme
Copy link
Member

I deployed this change in v0.3.1

@0xh3rman
Copy link
Contributor Author

I deployed this change in v0.3.1

Appreciate it, I'm debugging another memory issue might relate to the usage of slice like [TickArrayFacade; 6] in the ffi context in Swift, will create an issue or pr if I can fix it

@wjthieme
Copy link
Member

Awesome, thanks! Happy to help debugging if you get stuck

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.

2 participants