-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 zv: Prevent f32::NAN from causing panic
The range check would fail on NAN, INFINITY and NEG_INFINITY even if they are completely valid things to decode. This does not promise that an encoded NAN will be bit-wise identical as the decoded NAN, but if signalling NAN is used that precisely the user can have a handful of more interesting problems. As the decoding of an invalid f64=>f32 shouldn't be a panic, but a proper error, it means that f64_to_be can better be folded into the code in the deserialiser. Since this is floating point, we may also have fun rounding errors as an f64 may be too _small_ to be represented in an f32 and we may thus have precision loss as well, that seems annoying to deal with so hopefully whomever notices that in the future will have a good time. As I looked at the code, it seems usize => u32/u8 will have the same "crash the program" kind of conversions in them as well. Fixes: #1145
- Loading branch information
Showing
3 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters