Skip to content

Commit f5f8559

Browse files
committed
Reserve 8 bytes per format placeholder
1 parent 866ec24 commit f5f8559

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/core/src/fmt/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,9 @@ impl<'a> Arguments<'a> {
652652
// There are some arguments, so any additional push
653653
// will reallocate the string. To avoid that,
654654
// we're "pre-doubling" the capacity here.
655-
// It cannot overflow, because the maximum length is `isize::MAX`.
656-
pieces_length * 2
655+
pieces_length
656+
.checked_add(self.args.len().checked_mul(8).unwrap_or(0))
657+
.unwrap_or(pieces_length)
657658
}
658659
}
659660
}

0 commit comments

Comments
 (0)