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 f32 type conversion to be safe #350

Merged
merged 3 commits into from
Mar 30, 2021
Merged

Conversation

Virviil
Copy link
Contributor

@Virviil Virviil commented Mar 6, 2021

Decoding f32 is made using enif_get_double, which obviously consumes values bigger than f32:MAX.
Then, ret as f32 not limiting the value by it's max, either turn it to be f32:INFINITY. This leads to confusions and even nif panics.

@evnu evnu requested a review from a team March 29, 2021 13:14
Copy link
Member

@evnu evnu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your pull request! Sorry for taking so long for the review.

rustler/src/types/primitive.rs Outdated Show resolved Hide resolved
rustler/src/types/primitive.rs Show resolved Hide resolved
rustler/src/types/primitive.rs Outdated Show resolved Hide resolved
@Virviil Virviil requested a review from evnu March 29, 2021 21:46
@Virviil
Copy link
Contributor Author

Virviil commented Mar 30, 2021

I'm not sure why clippy check fails, it will be perfect if someone can check it out.

Copy link
Member

@evnu evnu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Can you rebase on master to get rid of the clippy lint? After that we are good to go.

@evnu evnu merged commit e5d7e3d into rusterlium:master Mar 30, 2021
@evnu
Copy link
Member

evnu commented Mar 30, 2021

Thanks again @Virviil !

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.

None yet

2 participants