Skip to content

Fix panic with high precision #5788

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

Merged
merged 2 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/literal/src/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub fn format_fixed(precision: usize, magnitude: f64, case: Case, alternate_form
match magnitude {
magnitude if magnitude.is_finite() => {
let point = decimal_point_or_empty(precision, alternate_form);
let precision = std::cmp::min(precision, u16::MAX as usize);
format!("{magnitude:.precision$}{point}")
}
magnitude if magnitude.is_nan() => format_nan(case),
Expand Down
3 changes: 3 additions & 0 deletions vm/src/stdlib/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ mod _io {
}

fn write(&mut self, data: &[u8]) -> Option<u64> {
if data.is_empty() {
return Some(0);
}
let length = data.len();
self.cursor.write_all(data).ok()?;
Some(length as u64)
Expand Down
Loading