Skip to content

Commit 5e682e3

Browse files
authored
Merge pull request RustPython#5788 from coolreader18/fix-prec
Fix panic with high precision
2 parents 2c02e27 + 163296d commit 5e682e3

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

compiler/literal/src/float.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub fn format_fixed(precision: usize, magnitude: f64, case: Case, alternate_form
5555
match magnitude {
5656
magnitude if magnitude.is_finite() => {
5757
let point = decimal_point_or_empty(precision, alternate_form);
58+
let precision = std::cmp::min(precision, u16::MAX as usize);
5859
format!("{magnitude:.precision$}{point}")
5960
}
6061
magnitude if magnitude.is_nan() => format_nan(case),

vm/src/stdlib/io.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ mod _io {
259259
}
260260

261261
fn write(&mut self, data: &[u8]) -> Option<u64> {
262+
if data.is_empty() {
263+
return Some(0);
264+
}
262265
let length = data.len();
263266
self.cursor.write_all(data).ok()?;
264267
Some(length as u64)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy