Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e8eac7b

Browse files
committedMar 13, 2025
fix: avoid overflow in linker E2BIG check
1 parent 0668c88 commit e8eac7b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎compiler/rustc_codegen_ssa/src/back/command.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ impl Command {
167167
//
168168
// [1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
169169
// [2]: https://devblogs.microsoft.com/oldnewthing/?p=41553
170-
let estimated_command_line_len = self.args.iter().map(|a| a.len()).sum::<usize>();
170+
let estimated_command_line_len = self
171+
.args
172+
.iter()
173+
.fold(0usize, |acc, a| acc.saturating_add(a.as_encoded_bytes().len()));
171174
estimated_command_line_len > 1024 * 6
172175
} else if cfg!(unix) {
173176
// On Unix the limits can be gargantuan anyway so we're pretty

0 commit comments

Comments
 (0)
Failed to load comments.